Class UnweightedShortestPath<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.shortestpath.UnweightedShortestPath<V,E>
-
- All Implemented Interfaces:
Distance<V>,ShortestPath<V,E>
public class UnweightedShortestPath<V,E> extends java.lang.Object implements ShortestPath<V,E>, Distance<V>
Computes the shortest path distances for graphs whose edges are not weighted (using BFS).
-
-
Constructor Summary
Constructors Constructor Description UnweightedShortestPath(edu.uci.ics.jung.graph.Hypergraph<V,E> g)Constructs and initializes algorithm
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.NumbergetDistance(V source, V target)Returns the distance from thesourcevertex to thetargetvertex.java.util.Map<V,java.lang.Number>getDistanceMap(V source)Returns aMapwhich maps each vertex in the graph (including thesourcevertex) to its distance (represented as a Number) fromsource.java.util.Map<V,E>getIncomingEdgeMap(V source)Returns aMapwhich maps each vertex in the graph (including thesourcevertex) to the last edge on the shortest path from thesourcevertex.voidreset()Clears all stored distances for this instance.voidreset(V v)Clears all stored distances for the specified source vertexsource.
-
-
-
Method Detail
-
getDistance
public java.lang.Number getDistance(V source, V target)
Description copied from interface:DistanceReturns the distance from thesourcevertex to thetargetvertex. Iftargetis not reachable fromsource, returns null.- Specified by:
getDistancein interfaceDistance<V>- See Also:
Distance.getDistance(Object, Object)
-
getDistanceMap
public java.util.Map<V,java.lang.Number> getDistanceMap(V source)
Description copied from interface:DistanceReturns a
Mapwhich maps each vertex in the graph (including thesourcevertex) to its distance (represented as a Number) fromsource. If any vertex is not reachable fromsource, no distance is stored for that vertex.- Specified by:
getDistanceMapin interfaceDistance<V>- See Also:
Distance.getDistanceMap(Object)
-
getIncomingEdgeMap
public java.util.Map<V,E> getIncomingEdgeMap(V source)
Description copied from interface:ShortestPathReturns a
Mapwhich maps each vertex in the graph (including thesourcevertex) to the last edge on the shortest path from thesourcevertex.- Specified by:
getIncomingEdgeMapin interfaceShortestPath<V,E>- See Also:
ShortestPath.getIncomingEdgeMap(Object)
-
reset
public void reset()
Clears all stored distances for this instance. Should be called whenever the graph is modified (edge weights changed or edges added/removed). If the user knows that some currently calculated distances are unaffected by a change,reset(V)may be appropriate instead.- See Also:
reset(Object)
-
-