/** * Note that, the source should not be as same as the sink! (we could extend * this later on) * * @param sourceVertex * @param sinkVertex * @return */ public Path GetShortestPath(BaseVertex sourceVertex, BaseVertex sinkVertex) { DetermineShortestPaths(sourceVertex, sinkVertex, true); // java.util.LinkedList <BaseVertex> vertexList = new java.util.LinkedList <BaseVertex>(); double weight = startVertexDistanceIndex.ContainsKey(sinkVertex) ? startVertexDistanceIndex[sinkVertex] : Graph.DISCONNECTED; if (weight != Graph.DISCONNECTED) { BaseVertex curVertex = sinkVertex; do { vertexList.add(curVertex); curVertex = predecessorIndex[curVertex]; } while (curVertex != null && curVertex != sourceVertex); vertexList.add(sourceVertex); vertexList.reverse(); } return(new Path(vertexList, weight)); }