V - etichette dei nodi del grafoE - etichette degli archi del grafopublic class BellmanFordShortestPathComputer<V extends PriorityQueueElement,E> extends java.lang.Object implements SingleSourceShortestPathComputer<V,E>
| Constructor and Description |
|---|
BellmanFordShortestPathComputer(Graph<V,E> graph)
Crea un calcolatore di cammini minimi a sorgente singola per un grafo
diretto e pesato.
|
| Modifier and Type | Method and Description |
|---|---|
void |
computeShortestPathsFrom(PriorityGraphNode<V> sourceNode)
Inizializza le informazioni necessarie associate ai nodi del grafo
associato a questo calcolatore ed esegue un algoritmo per il calcolo dei
cammini minimi a partire da una sorgente data.
|
Graph<V,E> |
getGraph()
Restituisce il grafo su cui opera questo calcolatore.
|
PriorityGraphNode<V> |
getLastSource()
Restituisce il nodo sorgente specificato nell'ultima chiamata effettuata
a
computeShortestPathsFrom(GraphNode<V>). |
java.util.List<GraphEdge<V,E>> |
getShortestPathTo(PriorityGraphNode<V> targetNode)
Restituisce una lista di archi dal nodo sorgente dell'ultimo calcolo di
cammini minimi al nodo passato.
|
boolean |
isComputed()
Determina se è stata invocata almeno una volta la procedura di calcolo
dei cammini minimi a partire da un certo nodo sorgente specificato.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprintPathpublic BellmanFordShortestPathComputer(Graph<V,E> graph)
graph - il grafo su cui opera il calcolatore di cammini minimijava.lang.NullPointerException - se il grafo passato è nullojava.lang.IllegalArgumentException - se il grafo passato è vuotojava.lang.IllegalArgumentException - se il grafo passato non è direttojava.lang.IllegalArgumentException - se il grafo passato non è pesato,
cioè esiste almeno un arco il cui
peso è Double.NaN.public void computeShortestPathsFrom(PriorityGraphNode<V> sourceNode)
SingleSourceShortestPathComputercomputeShortestPathsFrom in interface SingleSourceShortestPathComputer<V extends PriorityQueueElement,E>sourceNode - il nodo sorgente da cui calcolare i cammini minimi
verso tutti gli altri nodi del grafopublic boolean isComputed()
SingleSourceShortestPathComputerisComputed in interface SingleSourceShortestPathComputer<V extends PriorityQueueElement,E>public PriorityGraphNode<V> getLastSource()
SingleSourceShortestPathComputercomputeShortestPathsFrom(GraphNode<V>).getLastSource in interface SingleSourceShortestPathComputer<V extends PriorityQueueElement,E>public Graph<V,E> getGraph()
SingleSourceShortestPathComputergetGraph in interface SingleSourceShortestPathComputer<V extends PriorityQueueElement,E>public java.util.List<GraphEdge<V,E>> getShortestPathTo(PriorityGraphNode<V> targetNode)
SingleSourceShortestPathComputergetShortestPathTo in interface SingleSourceShortestPathComputer<V extends PriorityQueueElement,E>targetNode - il nodo verso cui restituire il cammino minimo
dalla sorgentenull se il nodo passato non è raggiungibile dalla
sorgente