11 fixed formatting edited May 22 '16 at 22:33 Rashid 1,32866 silver badges1818 bronze badges **Step 3 - Give every vertix a path dependent name (EDITED to be label each vertex with a path list) **Step 3 - Give every vertix a path dependent name (EDITED to label each vertex with a path list). For example, the path list {1,5,3,2} can be relabeled as {{1},{1,5},{1,5,3},{1,5,3,2}}. These labels will help us group all 1->5 paths in the first step together. **Step 3 - Give every vertix a path dependent name (EDITED to be label each vertex with a path list) **. For example, the path list {1,5,3,2} can be relabeled as {{1},{1,5},{1,5,3},{1,5,3,2}}. These labels will help us group all 1->5 paths in the first step together. Step 3 - Give every vertix a path dependent name (EDITED to label each vertex with a path list). For example, the path list {1,5,3,2} can be relabeled as {{1},{1,5},{1,5,3},{1,5,3,2}}. These labels will help us group all 1->5 paths in the first step together. 10 corrected typos within intro edited May 22 '16 at 22:03 Rashid 1,32866 silver badges1818 bronze badges @AntonAntonov's answer with the TriesWithFrequencies.m package is more elegant and useful that calculates deadlocks in the , but here is a brute force approach without any extra packages. @AntonAntonov's answer with the TriesWithFrequencies.m package is more elegant and useful that calculates deadlocks in the , but here is a brute force approach without any extra packages. @AntonAntonov's answer with the TriesWithFrequencies.m package is more elegant and useful, but here is a brute force approach without any extra packages. 9 fixed typos in module (where exampleGraph should have been graph), added butterfly graph example edited May 22 '16 at 20:45 Rashid 1,32866 silver badges1818 bronze badges UPDATE: Example with more than 10 verticesButterflyGraph[2, VertexLabels -> "Name", ImageSize -> Medium] pathTreeGraph[ButterflyGraph[2], 1, 2]  UPDATE: Example with more than 10 verticesButterflyGraph[2, VertexLabels -> "Name", ImageSize -> Medium] pathTreeGraph[ButterflyGraph[2], 1, 2]  8 fixed typos in module (where exampleGraph should have been graph) edited May 22 '16 at 20:37 Rashid 1,32866 silver badges1818 bronze badges 7 Generalized to label vertices with lists (to allow more than 10 nodes) and made labels clearer edited May 22 '16 at 20:31 Rashid 1,32866 silver badges1818 bronze badges 6 added 135 characters in body edited May 22 '16 at 15:07 Rashid 1,32866 silver badges1818 bronze badges 5 deleted code summary (redundant given module form) edited May 22 '16 at 13:12 Rashid 1,32866 silver badges1818 bronze badges 4 added module implementation edited May 22 '16 at 13:10 Rashid 1,32866 silver badges1818 bronze badges 3 added maxVertexValue to make code a little more general edited May 22 '16 at 12:59 Rashid 1,32866 silver badges1818 bronze badges 2 referenced better answer and provided some context for this approach edited May 22 '16 at 2:55 Rashid 1,32866 silver badges1818 bronze badges 1 answered May 22 '16 at 2:42 Rashid 1,32866 silver badges1818 bronze badges