org.caida.otter
Class DirectedGraph

java.lang.Object
  |
  +--org.caida.otter.DirectedGraph

public class DirectedGraph
extends java.lang.Object

Represent a directed graph, support simple queries on the graph The name field of the graph node should/will be unique because the nodes are kept track of with a hashtable keying on name. Constructors do a shallow copy for new elements.


Constructor Summary
DirectedGraph()
          Construct an empty graph
 
Method Summary
 boolean addPath(GraphNode root, java.lang.String source)
          Add a path to the graph.
 int calcMaxDepth(java.util.Vector sources, java.lang.String sourceName)
          Read in a Vector of GraphNodes that will serve as sourcee for the calcMaxDepth algorithm
 GraphNode[] getAllNodes()
          Return array of all nodes
 java.lang.String[] getAllSources()
          Return all the sources that have been stored in the graph
 java.util.Vector getChildren(java.lang.String source, java.lang.String name)
          Retrieve all the neighbors of a node
 int getGraphSize()
          Return the count of nodes in the graph
 int getMaxDepth(java.lang.String sourceName)
          Return the depth from source to destination if calcMaxDepth() has already been called, -1 otherwise
 GraphNode getNode(java.lang.String name)
          Get a GraphNode by its name
 boolean getOrientation(java.lang.String sourceName)
          Query of a given source is oriented foward or backward in the graph
 java.lang.Object sourceHashGet(java.lang.String getName)
           
 java.lang.Object sourceHashPut(java.lang.String putName, java.lang.Object putThing)
           
 int sourceHashSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectedGraph

public DirectedGraph()
Construct an empty graph
Method Detail

addPath

public boolean addPath(GraphNode root,
                       java.lang.String source)
Add a path to the graph. Adds a series of nodes that are connected directionally from first to last. Ignores redundancies, inserts new data.
Parameters:
graphNodeList - Vector of nodes specifying a path from the first element of the array to the last
Returns:
true if success, false if failue to add all data

getChildren

public java.util.Vector getChildren(java.lang.String source,
                                    java.lang.String name)
Retrieve all the neighbors of a node
Parameters:
name - Name of the GraphNode to return the children of.
Returns:
Vector of nodes that are neighbors, null if the node does not exist.

getGraphSize

public int getGraphSize()
Return the count of nodes in the graph
Returns:
The size of the graph.

getAllNodes

public GraphNode[] getAllNodes()
Return array of all nodes
Returns:
An array of all the nodes in the graph

getMaxDepth

public int getMaxDepth(java.lang.String sourceName)
Return the depth from source to destination if calcMaxDepth() has already been called, -1 otherwise
Returns:
The maxdepth of the graph.

getOrientation

public boolean getOrientation(java.lang.String sourceName)
Query of a given source is oriented foward or backward in the graph
Returns:
The direction of the source.

calcMaxDepth

public int calcMaxDepth(java.util.Vector sources,
                        java.lang.String sourceName)
Read in a Vector of GraphNodes that will serve as sourcee for the calcMaxDepth algorithm
Parameters:
sources - A Vector of all the sources to use when calculating the max depth.

getAllSources

public java.lang.String[] getAllSources()
Return all the sources that have been stored in the graph
Returns:
An array of all the source names.

getNode

public GraphNode getNode(java.lang.String name)
Get a GraphNode by its name
Parameters:
name - The name of the GraphNode to look up.
Returns:
The GraphNode object corresponding to the name, otherwise null.

sourceHashGet

public java.lang.Object sourceHashGet(java.lang.String getName)

sourceHashPut

public java.lang.Object sourceHashPut(java.lang.String putName,
                                      java.lang.Object putThing)

sourceHashSize

public int sourceHashSize()