com.arsdigita.util
Interface Graph

All Known Implementing Classes:
GraphSet

public interface Graph

The graph class allows you to build graphs of objects.

Since:
2003-01-22
Version:
$Date: 2004/04/07 $
Author:
Archit Shah (ashah@mit.edu), Vadim Nasardinov (vadimn@redhat.com)

Nested Class Summary
static interface Graph.Edge
          An edge is an ordered pair of nodes with a label attached to it.
 
Method Summary
 void addEdge(Graph.Edge edge)
          Adds an edge to the graph.
 void addEdge(Object tail, Object head, Object label)
          A convenient shortcut for addEdge(new Graph.Edge(tail, head, label)).
 void addNode(Object node)
          Adds a node to the graph.
 Graph copy()
          Creates a copy of this graph.
 List getIncomingEdges(Object node)
           
 String getLabel()
          Returns the graph's label.
 List getNodes()
          Returns a list of nodes that this graph has.
 List getOutgoingEdges(Object node)
          Returns a list of outgoing edges leaving this node.
 boolean hasEdge(Graph.Edge edge)
          Returns true if the graph has this edge.
 boolean hasNode(Object node)
          Returns true if the graph has this node.
 int incomingEdgeCount(Object node)
           
 int nodeCount()
          Returns the count of nodes in this graph.
 int outgoingEdgeCount(Object node)
          Returns the number of outgoing edges this node has.
 void removeAll()
          Removes all nodes and edges.
 boolean removeEdge(Graph.Edge edge)
          Removes specified edge.
 boolean removeEdge(Object tail, Object head, Object label)
          A convenient shortcut for removeEdge(new Graph.Edge(tail, head, label)).
 boolean removeNode(Object node)
          Removes specified node and all edges incident to it.
 void setLabel(String label)
          Sets the graph's label.
 

Method Detail

copy

public Graph copy()
Creates a copy of this graph.


setLabel

public void setLabel(String label)
Sets the graph's label.


getLabel

public String getLabel()
Returns the graph's label.


addNode

public void addNode(Object node)
Adds a node to the graph.


hasNode

public boolean hasNode(Object node)
Returns true if the graph has this node.


hasEdge

public boolean hasEdge(Graph.Edge edge)
Returns true if the graph has this edge.


nodeCount

public int nodeCount()
Returns the count of nodes in this graph.


addEdge

public void addEdge(Graph.Edge edge)
Adds an edge to the graph.


addEdge

public void addEdge(Object tail,
                    Object head,
                    Object label)
A convenient shortcut for addEdge(new Graph.Edge(tail, head, label)).

See Also:
addEdge(Graph.Edge)

getNodes

public List getNodes()
Returns a list of nodes that this graph has. (Todo: this should probably return a Set.)


removeNode

public boolean removeNode(Object node)
Removes specified node and all edges incident to it.


removeEdge

public boolean removeEdge(Object tail,
                          Object head,
                          Object label)
A convenient shortcut for removeEdge(new Graph.Edge(tail, head, label)).

See Also:
removeEdge(Graph.Edge)

removeEdge

public boolean removeEdge(Graph.Edge edge)
Removes specified edge.


removeAll

public void removeAll()
Removes all nodes and edges.


getOutgoingEdges

public List getOutgoingEdges(Object node)
Returns a list of outgoing edges leaving this node.


outgoingEdgeCount

public int outgoingEdgeCount(Object node)
Returns the number of outgoing edges this node has. A convenient shortcut for getOutgoingEdges(node).size().

See Also:
getOutgoingEdges(Object)

incomingEdgeCount

public int incomingEdgeCount(Object node)
See Also:
outgoingEdgeCount(Object)

getIncomingEdges

public List getIncomingEdges(Object node)
See Also:
getOutgoingEdges(Object)


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC