# All possible path in a network

hello all, I want to find an algorithm that finds all possible path lengths from the other nodes to specifically node 1in the network. I already know about dijkstra's algorithm for finding the shortest path length, what I need is an algorithm that tells me all the possible paths that can be taken without going through the same node more than once for each path, I have attached a picture of my network just to give you a visual of what am working with.  can anyone help me
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

IT Business Systems Analyst / Software DeveloperCommented:
The easiest way would probably be a recursive algorithm. Just go in reverse though. Start at node 1, and find the all possible paths that don't visit nodes twice. And then reverse these paths gives you all possible paths from all nodes back to node 1.

The recursive part would go like this, start at node 1 and find all possible adjoining nodes, then for each node found, recursively do just the same, ie. find all possible adjoining nodes of each node (except for the previously visited nodes in that path). The recursions terminating condition is when it visits a node where all possible adjoining nodes have already been visited. The paths found at the terminating conditions, and all intermediate paths are all solutions to what you are after. Note, that this will grow large with even a small number of nodes.
0
Commented:
Recursive algorithm

(a) Remove an edge and calculate all paths in smaller graph.
(a) Replace edge and work out other paths formed that contained the replaced edge.
I don't think this is that hard, (see below).
(c) Apply recursively.

If n is the chosen node for all paths to, and uv is removed edge. The the extra paths after replacement are formed by patching all sections of the u to n paths that do not have a vertex in common with a v to n path. Then repeat the other way around.
(This has a dynamic programming smell about it, else it is insanely non-polynomial.)
0

Experts Exchange Solution brought to you by