CITS2200
Interface Path


public interface Path

Path.java This interface is used to implement Prim's and Djikstra's algorithms over a weighted, undirected Graph.


Method Summary
 int getMinSpanningTree(Graph g)
          Finds the minimum weight of a spoanning tree for the given graph.
 int[] getShortestPaths(Graph g, int source)
          Runs Dijkstra's algorithm on a given undirected, non-negative weighted graph to find the distances to all vertices from the specified source vertex
 

Method Detail

getMinSpanningTree

int getMinSpanningTree(Graph g)
Finds the minimum weight of a spoanning tree for the given graph.

Parameters:
g - the Graph to be searched. Assume that an edge weight of 0 signifies that the edge does not exist.
Returns:
the weight of the minimum spanning tree, or -1 if there is no spanning tree

getShortestPaths

int[] getShortestPaths(Graph g,
                       int source)
Runs Dijkstra's algorithm on a given undirected, non-negative weighted graph to find the distances to all vertices from the specified source vertex

Parameters:
g - the Graph to be searched. Assume that an edge weight of 0 signifies that the edge does not exist.
source - the vertex on which to start the search
Returns:
an array listing the distance to each vertex in the single source shortest path problem, or -1 if the vertex is not reachable from the source.