Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
78c7df83
Commit
78c7df83
authored
Oct 05, 2015
by
Tiago Peixoto
Browse files
Move Graph.clear_vertex() fully into C++
parent
7e033535
Pipeline
#35
passed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/graph/graph_python_interface.cc
View file @
78c7df83
...
...
@@ -184,6 +184,19 @@ void remove_vertex(GraphInterface& gi, size_t v, bool fast)
}
}
struct
do_clear_vertex
{
template
<
class
Graph
>
void
operator
()(
Graph
&
g
,
size_t
v
)
const
{
clear_vertex
(
vertex
(
v
,
g
),
g
);
}
};
void
clear_vertex
(
GraphInterface
&
gi
,
size_t
v
)
{
run_action
<>
()(
gi
,
std
::
bind
(
do_clear_vertex
(),
placeholders
::
_1
,
v
))();
}
struct
add_new_edge
{
...
...
@@ -505,6 +518,8 @@ struct add_edge_list
for
(;
iter
!=
end
;
++
iter
)
eprops
.
emplace_back
(
*
iter
,
writable_edge_properties
());
size_t
n_props
=
std
::
min
(
eprops
.
size
(),
edge_list
.
shape
()[
1
]
-
2
);
for
(
const
auto
&
e
:
edge_list
)
{
size_t
s
=
e
[
0
];
...
...
@@ -512,7 +527,7 @@ struct add_edge_list
while
(
s
>=
num_vertices
(
g
)
||
t
>=
num_vertices
(
g
))
add_vertex
(
g
);
auto
ne
=
add_edge
(
vertex
(
s
,
g
),
vertex
(
t
,
g
),
g
).
first
;
for
(
size_t
i
=
0
;
i
<
e
.
size
()
-
2
;
++
i
)
for
(
size_t
i
=
0
;
i
<
n_props
;
++
i
)
{
try
{
...
...
@@ -918,6 +933,7 @@ void export_python_interface()
def
(
"add_vertex"
,
graph_tool
::
add_vertex
);
def
(
"add_edge"
,
graph_tool
::
add_edge
);
def
(
"remove_vertex"
,
graph_tool
::
remove_vertex
);
def
(
"clear_vertex"
,
graph_tool
::
clear_vertex
);
def
(
"remove_edge"
,
graph_tool
::
remove_edge
);
def
(
"add_edge_list"
,
graph_tool
::
do_add_edge_list
);
def
(
"add_edge_list_hashed"
,
graph_tool
::
do_add_edge_list_hashed
);
...
...
src/graph_tool/__init__.py
View file @
78c7df83
...
...
@@ -1845,11 +1845,7 @@ class Graph(object):
def
clear_vertex
(
self
,
vertex
):
"""Remove all in and out-edges from the given vertex."""
del_es
=
set
()
for
e
in
vertex
.
all_edges
():
del_es
.
add
(
e
)
for
e
in
del_es
:
self
.
remove_edge
(
e
)
libcore
.
clear_vertex
(
self
.
__graph
,
int
(
vertex
))
def
add_edge
(
self
,
source
,
target
,
add_missing
=
True
):
"""Add a new edge from ``source`` to ``target`` to the graph, and return
...
...
Write
Preview
Supports
Markdown
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