CITS2200
Interface Search


public interface Search

Search.java This interface specifies methods based on a Breadth First Search and Depth First Search over a directed Graph.


Method Summary
 int[] getConnectedTree(Graph g, int startVertex)
          Runs a BFS on a given directed, unweighted graph.
 int[] getDistances(Graph g, int startVertex)
          Runs a BFS on a given directed, unweighted graph to find the distances of vertices from the start vertex.
 int[][] getTimes(Graph g, int startVertex)
          Runs a DFS on a given directed, unweighted graph to find the start time and finish time for each vertex
 

Method Detail

getConnectedTree

int[] getConnectedTree(Graph g,
                       int startVertex)
Runs a BFS on a given directed, unweighted graph.

Parameters:
g - the Graph to be searched
startVertex - the vertex on which to start the search
Returns:
an array listing the parent of each vertex in the spanning tree, or -1 is the vertex is not reachable from the start vertex.

getDistances

int[] getDistances(Graph g,
                   int startVertex)
Runs a BFS on a given directed, unweighted graph to find the distances of vertices from the start vertex.

Parameters:
g - the Graph to be searched
startVertex - the vertex on which to start the search
Returns:
an array listing the distance of each vertex from the start vertex of each, or -1 is the vertex is not reachable from the start vertex.

getTimes

int[][] getTimes(Graph g,
                 int startVertex)
Runs a DFS on a given directed, unweighted graph to find the start time and finish time for each vertex

Parameters:
g - the Graph to be searched
startVertex - the vertex on which to start the search
Returns:
a 2-diimensional array, where each sub-array has two elements: the first is the start time, the second is the end time.