annas.graph.util
Class Floyd<N,A extends ArcInterface<N>>

java.lang.Object
  extended by annas.graph.util.Floyd<N,A>
Type Parameters:
N - Node type
A - Arc type

public class Floyd<N,A extends ArcInterface<N>>
extends java.lang.Object

Determines all pair shortest paths, as described here

Author:
Sam Wilson

Constructor Summary
Floyd(GraphInterface<N,A> g)
          Default constructor
 
Method Summary
 double[][] getD()
          The distance matrix for the current graph.
 double getDistance(N A, N B)
          Finds the distance between the two nodes, by looking in the distance matrix.
 int[][] getR()
          The route matrix for the current graph.
 GraphPath<N,A> getRoute(N A, N B)
          Find the route through the Graph from the source node to the destination node, by using the route matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Floyd

public Floyd(GraphInterface<N,A> g)
Default constructor

Parameters:
g - Graph o perform algorithm on.
Method Detail

getR

public int[][] getR()
The route matrix for the current graph.

Returns:
The route matrix.

getD

public double[][] getD()
The distance matrix for the current graph.

Returns:
distance matrix

getDistance

public double getDistance(N A,
                          N B)
Finds the distance between the two nodes, by looking in the distance matrix.

Parameters:
A - Source
B - Destination
Returns:
Distance between the nodes.

getRoute

public GraphPath<N,A> getRoute(N A,
                               N B)
Find the route through the Graph from the source node to the destination node, by using the route matrix.

Parameters:
A - Source
B - Destination
Returns:
Graph of the route between the two nodes.