edu.uconn.mcb.lineageevolver.graph
Class EdgeListGraph

java.lang.Object
  extended byedu.uconn.mcb.lineageevolver.graph.EdgeListGraph
All Implemented Interfaces:
DirectedGraph
Direct Known Subclasses:
EdgeListGraphTopology

public class EdgeListGraph
extends java.lang.Object
implements DirectedGraph

Comment for this type goes here.

Author:
Hasan Khalil

Field Summary
private  java.util.ArrayList _edges
          Our list of edges.
private  java.util.ArrayList _nodes
          Our list of nodes.
 
Constructor Summary
EdgeListGraph()
          Default constructor for objects of type EdgeListGraph.
 
Method Summary
 GraphEdge addEdge(java.lang.Object data, GraphNode origin, GraphNode destination)
          Adds an edge to this graph.
 GraphNode addNode(java.lang.Object data)
          Adds a node to this graph.
 GraphNode[] getAdjacentNodes(GraphNode v)
          Retrieves all nodes directly adjacent to the given node.
 java.lang.Object getData(GraphEdge e)
          Returns the data stored inside a given edge.
 java.lang.Object getData(GraphNode v)
          Returns the data stored inside a given node.
 GraphEdge[] getEdges(GraphNode v)
          Retrieves all edges outgoing from a given node.
 GraphNode[] getNodes()
          Retrieves all nodes in this graph.
 GraphNode[] getNodes(GraphEdge e)
          Retrieves the two nodes connected by a given edge.
 void setData(GraphEdge e, java.lang.Object data)
          Sets the data for a given edge.
 void setData(GraphNode v, java.lang.Object data)
          Sets the data for a given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_edges

private java.util.ArrayList _edges
Our list of edges.


_nodes

private java.util.ArrayList _nodes
Our list of nodes.

Constructor Detail

EdgeListGraph

public EdgeListGraph()
Default constructor for objects of type EdgeListGraph.

Method Detail

getEdges

public GraphEdge[] getEdges(GraphNode v)
Description copied from interface: DirectedGraph
Retrieves all edges outgoing from a given node.

Specified by:
getEdges in interface DirectedGraph
Parameters:
v - the node for which to retrieve the edges.
Returns:
an array containing all edges outgoing from the given node.
See Also:
DirectedGraph.getEdges(edu.uconn.mcb.lineageevolver.graph.GraphNode)

getNodes

public GraphNode[] getNodes(GraphEdge e)
Description copied from interface: DirectedGraph
Retrieves the two nodes connected by a given edge.

Specified by:
getNodes in interface DirectedGraph
Parameters:
e - the edge for which to retrieve the nodes.
Returns:
an array containing the two nodes connected to the given edge, with the origin node first, and the destination node last.
See Also:
DirectedGraph.getNodes(edu.uconn.mcb.lineageevolver.graph.GraphEdge)

addNode

public GraphNode addNode(java.lang.Object data)
Description copied from interface: DirectedGraph
Adds a node to this graph.

Specified by:
addNode in interface DirectedGraph
Parameters:
data - the data to store in the new node.
Returns:
the newly created node.
See Also:
DirectedGraph.addNode(java.lang.Object)

addEdge

public GraphEdge addEdge(java.lang.Object data,
                         GraphNode origin,
                         GraphNode destination)
Description copied from interface: DirectedGraph
Adds an edge to this graph.

Specified by:
addEdge in interface DirectedGraph
Parameters:
data - the data to store in the new edge.
origin - the origin node of this edge.
destination - the destination node of this edge.
Returns:
the newly created edge.
See Also:
DirectedGraph.addEdge(java.lang.Object, edu.uconn.mcb.lineageevolver.graph.GraphNode, edu.uconn.mcb.lineageevolver.graph.GraphNode)

getNodes

public GraphNode[] getNodes()
Description copied from interface: DirectedGraph
Retrieves all nodes in this graph.

Specified by:
getNodes in interface DirectedGraph
Returns:
an array containing all nodes in this graph, in no assured order.
See Also:
Returns a deep copy of our local array of nodes, but a shallow copy of the nodes themselves.

getData

public java.lang.Object getData(GraphNode v)
Description copied from interface: DirectedGraph
Returns the data stored inside a given node.

Specified by:
getData in interface DirectedGraph
Parameters:
v - the node from which to retrieve data.
Returns:
the data contained in the given node.
See Also:
DirectedGraph.getData(edu.uconn.mcb.lineageevolver.graph.GraphNode)

getData

public java.lang.Object getData(GraphEdge e)
Description copied from interface: DirectedGraph
Returns the data stored inside a given edge.

Specified by:
getData in interface DirectedGraph
Parameters:
e - the edge from which to retrieve data.
Returns:
the data contained in the given edge.
See Also:
DirectedGraph.getData(edu.uconn.mcb.lineageevolver.graph.GraphEdge)

setData

public void setData(GraphNode v,
                    java.lang.Object data)
Description copied from interface: DirectedGraph
Sets the data for a given node.

Specified by:
setData in interface DirectedGraph
Parameters:
v - the node for which to set the data.
data - the data to store inside the given node.
See Also:
DirectedGraph.setData(edu.uconn.mcb.lineageevolver.graph.GraphNode, java.lang.Object)

setData

public void setData(GraphEdge e,
                    java.lang.Object data)
Description copied from interface: DirectedGraph
Sets the data for a given edge.

Specified by:
setData in interface DirectedGraph
Parameters:
e - the edge for which to set the data.
data - the data to store inside the given edge.
See Also:
DirectedGraph.setData(edu.uconn.mcb.lineageevolver.graph.GraphEdge, java.lang.Object)

getAdjacentNodes

public GraphNode[] getAdjacentNodes(GraphNode v)
Description copied from interface: DirectedGraph
Retrieves all nodes directly adjacent to the given node. This means that they are reachable via the traversal of one edge.

Specified by:
getAdjacentNodes in interface DirectedGraph
Parameters:
v - the node for which to retrieve adjacent nodes.
Returns:
an array containing all adjacent nodes to the given node.
See Also:
This method does not ensure that there are no duplicate nodes in the returned array.