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
ed228c88
Commit
ed228c88
authored
Sep 18, 2013
by
Tiago Peixoto
Browse files
Fix issue with graph_union() and filtered graphs
parent
c249846a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/generation/__init__.py
View file @
ed228c88
...
@@ -935,7 +935,42 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
...
@@ -935,7 +935,42 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
if
props
==
None
:
if
props
==
None
:
props
=
[]
props
=
[]
if
not
include
:
if
not
include
:
g1
=
Graph
(
g1
)
g1
=
GraphView
(
g1
,
skip_properties
=
True
)
p1s
=
[]
for
i
,
(
p1
,
p2
)
in
enumerate
(
props
):
if
p1
is
None
:
continue
if
p1
.
key_type
()
==
"v"
:
g1
.
vp
[
str
(
i
)]
=
p1
elif
p1
.
key_type
()
==
"e"
:
g1
.
ep
[
str
(
i
)]
=
p1
g1
=
Graph
(
g1
,
prune
=
True
)
for
i
,
(
p1
,
p2
)
in
enumerate
(
props
):
if
p1
is
None
:
continue
if
str
(
i
)
in
g1
.
vp
:
props
[
i
]
=
(
g1
.
vp
[
str
(
i
)],
p2
)
del
g1
.
vp
[
str
(
i
)]
else
:
props
[
i
]
=
(
g1
.
ep
[
str
(
i
)],
p2
)
del
g1
.
ep
[
str
(
i
)]
else
:
emask
,
emask_flip
=
g1
.
get_edge_filter
()
emask_flipped
=
False
if
emask
is
not
None
and
not
emask_flip
:
emask
.
a
=
not
emask
.
a
emask_flipped
=
True
g1
.
set_edge_filter
(
emask
,
True
)
vmask
,
vmask_flip
=
g1
.
get_vertex_filter
()
vmask_flipped
=
False
if
vmask
is
not
None
and
not
vmask_flip
:
vmask
.
a
=
not
vmask
.
a
g1
.
set_vertex_filter
(
vmask
,
True
)
vmask_flipped
=
True
if
intersection
is
None
:
if
intersection
is
None
:
intersection
=
g1
.
new_vertex_property
(
"int32_t"
)
intersection
=
g1
.
new_vertex_property
(
"int32_t"
)
intersection
.
a
=
0
intersection
.
a
=
0
...
@@ -951,6 +986,18 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
...
@@ -951,6 +986,18 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
u2
.
_Graph__graph
,
u2
.
_Graph__graph
,
_prop
(
"v"
,
g1
,
_prop
(
"v"
,
g1
,
intersection
))
intersection
))
if
include
:
emask
,
emask_flip
=
g1
.
get_edge_filter
()
if
emask
is
not
None
and
emask_flipped
:
emask
.
a
=
not
emask
.
a
g1
.
set_edge_filter
(
emask
,
False
)
vmask
,
vmask_flip
=
g1
.
get_vertex_filter
()
if
vmask
is
not
None
and
vmask_flipped
:
vmask
.
a
=
not
vmask
.
a
g1
.
set_vertex_filter
(
vmask
,
False
)
n_props
=
[]
n_props
=
[]
for
p1
,
p2
in
props
:
for
p1
,
p2
in
props
:
if
p1
is
None
:
if
p1
is
None
:
...
...
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