Graph to forest

Functions

template<class G>
std::pair<Tree, std::vector<int>> graphToForest(const G &g)

Converts a graph to a forest. Returns a pair containing:

  • the forest

  • the IDs of the edges in a vector: for each vertex v, the value contained at the index v is the ID of the edge connecting v to its parent in the graph (or -1 if the vertex is a root)