Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'All Paths in a Graph' topicStudent Support Forum > General > "All Paths in a Graph"

Next Comment >Help | Reply To Topic
Author Comment/Response
James Rohal
08/28/07 09:43am

I'm trying to get a list of every possible path from one vertex (v_1) to another (v_2) in a directed graph but I'm not sure how to do it. Let's say the function AllPaths[g,v_1,v_2] returns a list of all the paths in a (directed) graph g with each path being a list of vertices in the path from v_1 to v_2. As a simple example:

In[1]:= directedGraph = SetGraphOptions[GridGraph[3, 4], EdgeDirection -> On];


Out[2]:= {{1,2,3,6,9,12}, {1,2,5,6,9,12}, {1,2,5,8,9,12}, {1,2,5,8,11,12}, {1,4,5,6,9,12}, {1,4,5,8,9,12}, etc.....}

I didn't write out the entire input, but I think it should be clear what I'm trying to achieve. Is there any easy way to program this?

Thanks in advance.

URL: ,

Subject (listing for 'All Paths in a Graph')
Author Date Posted
All Paths in a Graph James Rohal 08/28/07 09:43am
Re: All Paths in a Graph yehuda ben-s... 08/29/07 3:30pm
Re: Re: All Paths in a Graph James Rohal 08/29/07 4:50pm
Next Comment >Help | Reply To Topic