Graphs: All paths between u and v

Like the title says, I am trying to find all the paths between u and v in a graph.
The graphs properties:
1)Connected
2)Not necessarily simple
3)Undirected
4)Unweighted

How would I go about this. I would like to print the paths out. Is there an algorithm for it? (I have yet to find one)
Last edited on
Can a path contain the same node twice?
No cycles are allowed
I think this simple recursive algorithm should work.
1
2
3
4
5
6
7
8
findAllPaths(Node n, Path p, PathList& l)
	for all n's neighbour nodes m
		if m is not in p
			p' := p + m
			if m == v
				add p' to l
			else
				findAllPaths(m, p', l)
I think I have the solution, thank you.
Topic archived. No new replies allowed.