I am using graph-tool for python, a library which implements boost. I need to do a depth-first search using only edges which have the edge_property:
rel_need = True
So, i'm using
gt.dfs_search(g, g.vertex(0), NeedFinder(rel_need, pred, time))
with this DFSVisitor:
class NeedFinder(gt.DFSVisitor):
def __init__(self, rel_need, pred, time):
self.rel_need = rel_need
self.pred = pred
self.time = time
self.last_time = 0
def discover_vertex(self, u):
self.time[u] = self.last_time
self.last_time += 1
def examine_edge(self, e):
pass
def tree_edge(self, e):
if self.rel_need[e]:
self.pred[e.target()] = int(e.source())
It seems like I should be doing some sort of check in the examine_edge def, but I haven't been able to find docs explaining it. I have the check in the tree_edge def, which successfully filters all of the rel_need=true edges, but it doesn't change the traversal. How do I make a DFSVisitor that only traverses certain edges, and not all edges?