Dividing graph into branches

141 Views Asked by At

enter image description here

I would like to know an algorithm to produce a graph decomposition into branches with rank in the following way:

Rank | path (or tree branch)
0      1-2
1      2-3-4-5-6
1      2-7
2      7-8
2      7-9

The node 1 would be the Root node and the nodes 6, 8 and 9 would be the end nodes. the rank of a branch should be given by the number of bifurcation nodes up to the root node. Let's assume that the graph has no loops.

I am electrical engineer, and perhaps this is a very standard problem, but so far I have only found the BFS algorithm to get the paths, and all the cut sets stuff.

I hope that my question is clear enough.

PS: should this question be in stack overflow?