I have an array of set of node connections defined by:
var arr = ['1-2','1-6','2-6','2-3','1-4','1-5','6-7','4-7','7-8'];
1-2 means node 1 connects to node 2 and so on. There are multiple connections as you can see.
If correctly manipulated, you can notice various unique paths such as 1-2-6-7-8, 1-5 etc. I would like to calculate paths as:
path = ['1-2-6-7-8','1-6-7-8','1-2-3','1-4-7-8','1-5']
I have done by checking each set by another set but I think my code is too long and does not perform well. What is the best way to get path array. (path ends at leaf node)
Thanks.

How about this solution, and I think it only works with DAG: directed acyclic graphs
and when you call
go(), you get the following output