Commit 38276b9f authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Get rid of the filter stash in Graph class

Fully remove the filter stash and associated functions in the Graph
class, in favor of using GraphView uniquely.
parent 1f6f566f
This diff is collapsed.
...@@ -944,17 +944,14 @@ def graph_union(g1, g2, intersection=None, props=None, include=False): ...@@ -944,17 +944,14 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
intersection.a[intersection.a >= 0] += 1 intersection.a[intersection.a >= 0] += 1
intersection.a[intersection.a < 0] = 0 intersection.a[intersection.a < 0] = 0
g1.stash_filter(directed=True) u1 = GraphView(g1, directed=True, skip_properties=True)
g1.set_directed(True) u2 = GraphView(g2, directed=True, skip_properties=True)
g2.stash_filter(directed=True)
g2.set_directed(True)
n_props = []
try: vmap, emap = libgraph_tool_generation.graph_union(u1._Graph__graph,
vmap, emap = libgraph_tool_generation.graph_union(g1._Graph__graph, u2._Graph__graph,
g2._Graph__graph,
_prop("v", g1, _prop("v", g1,
intersection)) intersection))
n_props = []
for p1, p2 in props: for p1, p2 in props:
if not include: if not include:
p1 = g1.copy_property(p1) p1 = g1.copy_property(p1)
...@@ -962,20 +959,17 @@ def graph_union(g1, g2, intersection=None, props=None, include=False): ...@@ -962,20 +959,17 @@ def graph_union(g1, g2, intersection=None, props=None, include=False):
p2 = g2.copy_property(p2, value_type=p1.value_type()) p2 = g2.copy_property(p2, value_type=p1.value_type())
if p1.key_type() == 'v': if p1.key_type() == 'v':
libgraph_tool_generation.\ libgraph_tool_generation.\
vertex_property_union(g1._Graph__graph, g2._Graph__graph, vertex_property_union(u1._Graph__graph, u2._Graph__graph,
vmap, emap, vmap, emap,
_prop(p1.key_type(), g1, p1), _prop(p1.key_type(), g1, p1),
_prop(p2.key_type(), g2, p2)) _prop(p2.key_type(), g2, p2))
else: else:
libgraph_tool_generation.\ libgraph_tool_generation.\
edge_property_union(g1._Graph__graph, g2._Graph__graph, edge_property_union(u1._Graph__graph, u2._Graph__graph,
vmap, emap, vmap, emap,
_prop(p1.key_type(), g1, p1), _prop(p1.key_type(), g1, p1),
_prop(p2.key_type(), g2, p2)) _prop(p2.key_type(), g2, p2))
n_props.append(p1) n_props.append(p1)
finally:
g1.pop_filter(directed=True)
g2.pop_filter(directed=True)
if len(n_props) > 0: if len(n_props) > 0:
return g1, n_props return g1, n_props
......
...@@ -294,10 +294,10 @@ def edge_average(g, eprop): ...@@ -294,10 +294,10 @@ def edge_average(g, eprop):
def remove_labeled_edges(g, label): def remove_labeled_edges(g, label):
"""Remove every edge `e` such that `label[e] != 0`.""" """Remove every edge `e` such that `label[e] != 0`."""
g.stash_filter(all=False, directed=True, reversed=True) u = GraphView(g, directed=True, reversed=g.is_reversed(),
skip_properties=True)
libgraph_tool_stats.\ libgraph_tool_stats.\
remove_labeled_edges(g._Graph__graph, _prop("e", g, label)) remove_labeled_edges(u._Graph__graph, _prop("e", g, label))
g.pop_filter(all=False, directed=True, reversed=True)
def label_parallel_edges(g, mark_only=False, count_all=False, eprop=None): def label_parallel_edges(g, mark_only=False, count_all=False, eprop=None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment