@@ -0,0 +1,1523 @@
+package org.psjava.example;%0D%0A%0D%0Aimport junit.framework.Assert;%0D%0A%0D%0Aimport org.junit.Test;%0D%0Aimport org.psjava.algo.graph.shortestpath.SingleSourceShortestPath;%0D%0Aimport org.psjava.algo.graph.shortestpath.SingleSourceShortestPathResult;%0D%0Aimport org.psjava.ds.graph.DirectedWeightedEdge;%0D%0Aimport org.psjava.ds.graph.DirectedWeightedEdgeFactory;%0D%0Aimport org.psjava.ds.graph.MutableDirectedGraph;%0D%0Aimport org.psjava.goods.GoodSingleSourceShortestPath;%0D%0Aimport org.psjava.math.ns.IntegerNumberSystem;%0D%0A%0D%0Apublic class ShortestPathExample %7B%0D%0A%0D%0A%09@Test%0D%0A%09public void example() %7B%0D%0A%0D%0A%09%09// construct graph.%0D%0A%0D%0A%09%09MutableDirectedGraph%3CDirectedWeightedEdge%3CInteger%3E%3E graph = new MutableDirectedGraph%3CDirectedWeightedEdge%3CInteger%3E%3E();%0D%0A%09%09graph.insertVertex(%22A%22);%0D%0A%09%09graph.insertVertex(%22B%22);%0D%0A%09%09graph.insertVertex(%22C%22);%0D%0A%09%09graph.insertVertex(%22D%22);%0D%0A%09%09graph.addEdge(DirectedWeightedEdgeFactory.create(%22A%22, %22C%22, 100));%0D%0A%09%09graph.addEdge(DirectedWeightedEdgeFactory.create(%22A%22, %22B%22, 10));%0D%0A%09%09graph.addEdge(DirectedWeightedEdgeFactory.create(%22B%22, %22C%22, 20));%0D%0A%0D%0A%09%09// Let's calculate distances from 'A', the single source.%0D%0A%09%09// Choose algorithm, and calculate. The good one should be dijkstra%0D%0A%09%09// algorithm with binary heap.%0D%0A%0D%0A%09%09SingleSourceShortestPath algo = GoodSingleSourceShortestPath.getInstance();%0D%0A%09%09SingleSourceShortestPathResult%3CInteger, DirectedWeightedEdge%3CInteger%3E%3E result = algo.calc(graph, %22A%22, IntegerNumberSystem.getInstance());%0D%0A%0D%0A%09%09int distanceAToC = result.getDistance(%22C%22);%0D%0A%0D%0A%09%09Assert.assertEquals(30, distanceAToC);%0D%0A%09%7D%0D%0A%7D%0D%0A

add an example : shortest path.