For shortest paths look at: http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm and also: "An algorithm for computing all paths in a graph" by Lars-Erik Thorelli http://www.springerlink.com/content/t53j31t5012v6605/