@@ -0,0 +1,2214 @@
+package dijkstra;%0A%0Aimport org.jgrapht.ListenableGraph;%0Aimport org.jgrapht.alg.DijkstraShortestPath;%0Aimport org.jgrapht.graph.GraphDelegator;%0Aimport org.jgrapht.graph.ListenableUndirectedWeightedGraph;%0Aimport org.jgrapht.graph.DefaultWeightedEdge;%0A%0Aimport datastructure.Edge;%0Aimport datastructure.Node;%0A%0A/**%0A * Wrapper class for the library Dijkstra algorithm implementation%0A * @author Merlin Viernickel%0A * @date 24.06.2017%0A */%0Apublic class JGraphTDijkstra %7B%0A%09%0A%09private Node%5B%5D nodes;%0A%09%0A%09/**%0A%09 * Constructor%0A%09 * @param nodes Array of nodes to calculate distance from%0A%09 */%0A%09public JGraphTDijkstra(Node%5B%5D nodes)%7B%0A%09%09this.nodes = nodes;%0A%09%7D%0A%09%0A%09/**%0A     * Dijkstra algorithm that calculates the distance for all nodes and returns the furthest one%0A     * @return Node furthest from the starting node%0A%09 */%0A%09public Node findFurthestNode()%7B%0A        ListenableGraph%3CNode, DefaultWeightedEdge%3E graph = new ListenableUndirectedWeightedGraph%3CNode, DefaultWeightedEdge%3E(DefaultWeightedEdge.class);%0A        Node furthestNode = nodes%5B0%5D;%0A        %0A        /** Add vertices */%0A        for(int i=0; i%3Cnodes.length; i++)%7B%0A            graph.addVertex(nodes%5Bi%5D);%0A        %7D%0A        %0A        /** Add edges */%0A        for(int i=0; i%3Cnodes.length; i++)%7B%0A            Node node = nodes%5Bi%5D;%0A            for(int j=0; j%3Cnode.edges.size(); j++)%7B%0A                if(node.edges.get(j).head.equals(node))%7B%0A                %09DefaultWeightedEdge edge = new DefaultWeightedEdge();%0A                    graph.addEdge(node, node.edges.get(j).tail, edge);%0A                    ((GraphDelegator%3CNode, DefaultWeightedEdge%3E) graph).setEdgeWeight(edge, (double) node.edges.get(j).weight);%0A                %7D%0A            %7D%0A        %7D%0A        %0A        /** Calculate distances and find furthest Node */%0A        for(int i=1; i%3Cnodes.length; i++)%7B%0A            DijkstraShortestPath%3CNode, DefaultWeightedEdge%3E shortestPath =%0A            %09%09new DijkstraShortestPath%3CNode, DefaultWeightedEdge%3E(graph, nodes%5B0%5D, nodes%5Bi%5D);%0A            %0A            nodes%5Bi%5D.distance = (int) shortestPath.getPathLength();%0A            if(furthestNode.distance %3C nodes%5Bi%5D.distance)%7B%0A            %09furthestNode = nodes%5Bi%5D;%0A            %7D%0A        %7D%0A        %0A        return furthestNode;        %0A%09%7D%09%0A%0A%7D%0A

Add library dijkstra implementation