GraphView without efilt
I am not sure if this is a bug or a feature.
Code:
import graph_tool.all as gt
def implicit_efilt(vfilt):
G = vfilt.get_graph()
efilt = G.new_edge_property("bool")
efilt.a = False
Gv = gt.GraphView(G,vfilt=vfilt)
for e in Gv.edges(): efilt[e] = True
return efilt
def format_vlist(G):
return ",".join(map(str,G.vertices()))
def format_elist(G):
return ",".join(["({}->{})".format(e.source(),e.target()) for e in G.edges()])
G = gt.complete_graph(4)
print("G " + format_vlist(G) + " - " + format_elist(G))
vfilt = G.new_vertex_property("bool")
vfilt.a = True
vfilt[G.vertex(0)] = False
Gv = gt.GraphView(G,vfilt=vfilt)
print("Gv " + format_vlist(Gv) + " - " + format_elist(Gv))
for e in G.edges():
if Gv.edge(e.source(),e.target()) is not None:
print("Edge ({}->{}) is in Gv".format(e.source(),e.target()))
else:
print("Edge ({}->{}) is NOT in Gv".format(e.source(),e.target()))
Gv = gt.GraphView(G,vfilt=vfilt, efilt=implicit_efilt(vfilt))
print("Gv " + format_vlist(Gv) + " - " + format_elist(Gv))
for e in G.edges():
if Gv.edge(e.source(),e.target()) is not None:
print("Edge ({}->{}) is in Gv".format(e.source(),e.target()))
else:
print("Edge ({}->{}) is NOT in Gv".format(e.source(),e.target()))
Output
G 0,1,2,3 - (0->1),(0->2),(0->3),(1->2),(1->3),(2->3)
Gv 1,2,3 - (1->2),(1->3),(2->3)
Edge (0->1) is in Gv
Edge (0->2) is in Gv
Edge (0->3) is in Gv
Edge (1->2) is in Gv
Edge (1->3) is in Gv
Edge (2->3) is in Gv
Gv 1,2,3 - (1->2),(1->3),(2->3)
Edge (0->1) is NOT in Gv
Edge (0->2) is NOT in Gv
Edge (0->3) is NOT in Gv
Edge (1->2) is in Gv
Edge (1->3) is in Gv
Edge (2->3) is in Gv
The edge iterator of the filtered graph returns only edges between visible vertices. But the g.edge(s,t) method allows to retrieve edges between filtered vertices. Clearly, the edge filter is needed. Maybe it can be computed if only the vertex filter is given, or we simply update the documentation to explicitly describe the current behavior when an edge filter is not set?