Accessing all ancestors

Hello guys,

I am migrating from a code devised in networkx to Graph-tool.

Now, I need to get all ancestors in graph-tool. Could you guys help me out here.

I found the func all_predecessors, but I could not figured out how to use it.. since it is mandatory to pass diet_map and prep_map.

Can you please help me inhere :smiley:


We cannot help with generic questions about how to use a function.

There is a documentation that explains how to use it, and I cannot read
your mind to determine what you did or did not understand from it.

We can only help with specific questions.

Ok Tiago thanks.

My question is, given a source node how can I get all ancestors? I tried to use all_predecessors but I dunno what is dist_map and prep_map.

Question: Is possible to get all ancestors passing a node in graph-tool?


The documentation says:

  dist_map : :class:`~graph_tool.VertexPropertyMap`
     Vertex property map with the distances from ``source`` to all other
  pred_map : :class:`~graph_tool.VertexPropertyMap`
     Vertex property map with the predecessors in the search tree.

You can determine these values using the function shortest_distance():

   dist_map, pred_map = shortest_distance(g, source=u, pred_map=True)