edu.iu.iv.search.p2p.bfs
Class BreadthFirstSearch

java.lang.Object
  |
  +--edu.iu.iv.search.p2p.bfs.BreadthFirstSearch

public class BreadthFirstSearch
extends java.lang.Object

Breadth First Search Algorithm

Author:
Hardik Sheth (hsheth@indiana.edu)

Constructor Summary
BreadthFirstSearch()
           
BreadthFirstSearch(edu.uci.ics.jung.graph.Graph graph)
          Constructor for BreadthFirstSearch.
BreadthFirstSearch(edu.uci.ics.jung.graph.Graph graph, double threshold)
          Constructor for BreadthFirstSearch.
 
Method Summary
 java.lang.String getFailReason()
          Get the reason because of which modelig failed
 edu.uci.ics.jung.graph.impl.UndirectedSparseGraph getGraph()
          This method returns the graph on which search is performed
 int getNetworkSize()
          This method returns the network size
 int getSearchCost()
          This method returns the search cost (no. of messages for the search)
 double getThreshold()
          This method returns the threshold used to perform BFS
 boolean searchNetwork(int fromId, int toId)
          Perform BFS on the network
 boolean searchNetwork(int fromId, int toId, double threshold)
          Perform BFS on the network
 void setGraph(edu.uci.ics.jung.graph.impl.UndirectedSparseGraph graph)
          This method sets the graph on which search is to be performed
 void setThreshold(double threshold)
          This method sets the threhold with which BFS will be performed
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BreadthFirstSearch

public BreadthFirstSearch()

BreadthFirstSearch

public BreadthFirstSearch(edu.uci.ics.jung.graph.Graph graph)
Constructor for BreadthFirstSearch. Requires a graph to be passed that represents the network on which the search is to be performed.


BreadthFirstSearch

public BreadthFirstSearch(edu.uci.ics.jung.graph.Graph graph,
                          double threshold)
Constructor for BreadthFirstSearch. Requires a graph to be passed that represents the network on which the search is to be performed. and the threshold

Method Detail

searchNetwork

public boolean searchNetwork(int fromId,
                             int toId,
                             double threshold)
Perform BFS on the network

Parameters:
fromId - - source node from where search begins
toId - - target node to be found
threshold - - threshold to perform the BFS
Returns:
true if node found, false otherwise

searchNetwork

public boolean searchNetwork(int fromId,
                             int toId)
Perform BFS on the network

Parameters:
fromId - - source node from where search begins
toId - - target node to be found
Returns:
true if node found, false otherwise

getGraph

public edu.uci.ics.jung.graph.impl.UndirectedSparseGraph getGraph()
This method returns the graph on which search is performed

Returns:
graph

getNetworkSize

public int getNetworkSize()
This method returns the network size

Returns:
network size

getSearchCost

public int getSearchCost()
This method returns the search cost (no. of messages for the search)

Returns:
search cost

getThreshold

public double getThreshold()
This method returns the threshold used to perform BFS

Returns:
threshold

setGraph

public void setGraph(edu.uci.ics.jung.graph.impl.UndirectedSparseGraph graph)
This method sets the graph on which search is to be performed

Parameters:
graph -

setThreshold

public void setThreshold(double threshold)
This method sets the threhold with which BFS will be performed

Parameters:
threshold -

getFailReason

public java.lang.String getFailReason()
Get the reason because of which modelig failed

Returns:
reason