From: Christoph S. <cs...@gm...> - 2004-01-28 15:22:02
|
Hi, I'd like to make two suggestions which came up when I started using jung. (1) The Dijkstra shortest path algorithm returns shortest distances, but not the paths themselves. I extended it to maintain a predecessor map which allows me to reconstruct the actual shortest paths. So if a shortest path from v1 to v3 is (v1, v6, v4, v3) I will get getPredecessor(v3) == v4 getPredecessor(v4) == v6 getPredecessor(v6) == v1 From that one can easily build the path as a list or whatever. (2) GraphMatrixOperations.graphToSparseMatrix() returns a matrix which contains 0 in positions where no edge is present. Occasionally, one may want to have another value there (I wanted to have Double.POSITIVE_INFINITY, for example). I added a version of graphToSparseMatrix which lets me set a default value for those positions. Find attached modified versions of the respective source files (originals checked out from CVS an hour or so ago), plus some test cases. Best regards and thanks for the nice piece of software, Christoph -- -- Christoph Schmitz <cschm AT gmx.de> |