Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
40
Issues
40
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
d4980abf
Commit
d4980abf
authored
Jun 05, 2015
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Graph.edge() implementation to C++
parent
92d0c0b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
src/graph/graph_python_interface.cc
src/graph/graph_python_interface.cc
+30
-0
src/graph_tool/__init__.py
src/graph_tool/__init__.py
+1
-8
No files found.
src/graph/graph_python_interface.cc
View file @
d4980abf
...
...
@@ -213,6 +213,35 @@ void remove_edge(GraphInterface& gi, const python::object& e)
throw
ValueException
(
"invalid edge descriptor"
);
}
struct
get_edge_dispatch
{
template
<
class
Graph
>
void
operator
()(
Graph
&
g
,
const
python
::
object
&
pg
,
size_t
s
,
size_t
t
,
bool
all_edges
,
boost
::
python
::
list
&
es
)
const
{
for
(
auto
e
:
out_edges_range
(
vertex
(
s
,
g
),
g
))
{
if
(
target
(
e
,
g
)
==
vertex
(
t
,
g
))
{
es
.
append
(
PythonEdge
<
Graph
>
(
pg
,
e
));
if
(
!
all_edges
)
break
;
}
}
}
};
python
::
object
get_edge
(
python
::
object
g
,
size_t
s
,
size_t
t
,
bool
all_edges
)
{
GraphInterface
&
gi
=
python
::
extract
<
GraphInterface
&>
(
g
().
attr
(
"_Graph__graph"
));
python
::
list
es
;
run_action
<>
()(
gi
,
std
::
bind
(
get_edge_dispatch
(),
placeholders
::
_1
,
std
::
ref
(
g
),
s
,
t
,
all_edges
,
std
::
ref
(
es
)))();
return
es
;
}
struct
get_degree_map
{
template
<
class
Graph
,
class
DegS
,
class
Weight
>
...
...
@@ -467,6 +496,7 @@ void export_python_interface()
def
(
"remove_vertex"
,
graph_tool
::
remove_vertex
);
def
(
"remove_edge"
,
graph_tool
::
remove_edge
);
def
(
"add_edge_list"
,
graph_tool
::
do_add_edge_list
);
def
(
"get_edge"
,
get_edge
);
def
(
"get_vertex_index"
,
get_vertex_index
);
def
(
"get_edge_index"
,
do_get_edge_index
);
...
...
src/graph_tool/__init__.py
View file @
d4980abf
...
...
@@ -1475,14 +1475,7 @@ class Graph(object):
if
s
is
None
or
t
is
None
:
return
None
efilt
=
self
.
get_edge_filter
()
edges
=
[]
for
e
in
s
.
out_edges
():
if
efilt
[
0
]
is
not
None
and
efilt
[
0
][
e
]
==
efilt
[
1
]:
continue
if
e
.
target
()
==
t
:
if
not
all_edges
:
return
e
edges
.
append
(
e
)
edges
=
libcore
.
get_edge
(
weakref
.
ref
(
self
),
int
(
s
),
int
(
t
),
all_edges
)
if
add_missing
and
len
(
edges
)
==
0
:
edges
.
append
(
self
.
add_edge
(
s
,
t
))
if
all_edges
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment