Convert a general graph into a forestSource:
Perform a breadth-first search on a graph and convert it into a tree or forest by replicating vertices that were found more than once.
unfold_tree(graph, mode = c("all", "out", "in", "total"), roots)
The input graph, it can be either directed or undirected.
Character string, defined the types of the paths used for the breadth-first search. “out” follows the outgoing, “in” the incoming edges, “all” and “total” both of them. This argument is ignored for undirected graphs.
A vector giving the vertices from which the breadth-first search is performed. Typically it contains one vertex per component.
A list with two components:
The result, an
igraphobject, a tree or a forest.
A numeric vector, it gives a mapping from the vertices of the new graph to the vertices of the old graph.
A forest is a graph, whose components are trees.
roots vector can be calculated by simply doing a topological sort
in all components of the graph, see the examples below.
Gabor Csardi email@example.com