/* * Copyright (c) 2003, the JUNG Project and the Regents of the University * of California * All rights reserved. * * This software is open-source under the BSD license; see either * "license.txt" or * http://jung.sourceforge.net/license.txt for a description. */ package edu.uci.ics.jung.algorithms.shortestpath; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.collections15.Transformer; import edu.uci.ics.jung.graph.Graph; /** *
Calculates distances and shortest paths using Dijkstra's
* single-source-shortest-path algorithm. This is a lightweight
* extension of DijkstraDistance
that also stores
* path information, so that the shortest paths can be reconstructed.
The elements in the maps returned by
* getIncomingEdgeMap
are ordered (that is, returned
* by the iterator) by nondecreasing distance from source
.
Creates an instance of Creates an instance of Creates an instance of Creates an instance of Returns the last edge on a shortest path from If either vertex is not in the graph for which this instance
* was created, throws Returns a Returns a DijkstraShortestPath
for
* the specified graph and the specified method of extracting weights
* from edges, which caches results locally if and only if
* cached
is true
.
*
* @param g the graph on which distances will be calculated
* @param nev the class responsible for returning weights for edges
* @param cached specifies whether the results are to be cached
*/
public DijkstraShortestPath(GraphDijkstraShortestPath
for
* the specified graph and the specified method of extracting weights
* from edges, which caches results locally.
*
* @param g the graph on which distances will be calculated
* @param nev the class responsible for returning weights for edges
*/
public DijkstraShortestPath(GraphDijkstraShortestPath
for
* the specified unweighted graph (that is, all weights 1) which
* caches results locally.
*
* @param g the graph on which distances will be calculated
*/
public DijkstraShortestPath(GraphDijkstraShortestPath
for
* the specified unweighted graph (that is, all weights 1) which
* caches results locally.
*
* @param g the graph on which distances will be calculated
* @param cached specifies whether the results are to be cached
*/
public DijkstraShortestPath(Graphsource
* to target
, or null if target
is not
* reachable from source
.IllegalArgumentException
.LinkedHashMap
which maps each vertex
* in the graph (including the source
vertex)
* to the last edge on the shortest path from the
* source
vertex.
* The map's iterator will return the elements in order of
* increasing distance from source
.List
of the edges on the shortest path from
* source
to target
, in order of their
* occurrence on this path.
* If either vertex is not in the graph for which this instance
* was created, throws IllegalArgumentException
.
*/
public ListLinkedHashMap
which maps each of the closest
* numDist
vertices to the source
vertex
* in the graph (including the source
vertex)
* to the incoming edge along the path from that vertex. Throws
* an IllegalArgumentException
if source
* is not in this instance's graph, or if numDests
is
* either less than 1 or greater than the number of vertices in the
* graph.
*
* @see #getIncomingEdgeMap(Object)
* @see #getPath(Object,Object)
* @param source the vertex from which distances are measured
* @param numDests the number of vertics for which to measure distances
*/
public LinkedHashMap