de.rwth.graph
Class RootedGraph

java.lang.Object
  |
  +--de.rwth.graph.Graph
        |
        +--de.rwth.graph.RootedGraph
Direct Known Subclasses:
FactorisedFlowGraph, SwappedGraph

public class RootedGraph
extends Graph

This class represents a graph with roots and leafs.

Version:
$Id: RootedGraph.java,v 1.3 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen, Mario Joußen <joussen@i2.informatik.rwth-aachen.de>

Inner Class Summary
 class RootedGraph.Node
          This class represents a node in a RootedGraph.
 
Inner classes inherited from class de.rwth.graph.Graph
Graph.Node, Graph.NodeDyer
 
Field Summary
protected  java.util.HashSet leafs
          The set of leaf nodes.
protected  java.util.HashSet roots
          The set of root nodes.
 
Fields inherited from class de.rwth.graph.Graph
curNumber, label, nodes, sizeEdges
 
Constructor Summary
RootedGraph()
          Creates a new RootedGraph without a label.
RootedGraph(java.lang.Object label)
          Creates a new RootedGraph with a label.
 
Method Summary
 void addLeaf(Graph.Node node)
          Adds a node as one of the leafs of this graph.
 void addRoot(Graph.Node node)
          Adds a node as one of the roots of this graph.
 Graph.Node[] getLeafArray()
          Returns an array of all leaf nodes.
 java.util.Iterator getLeafs()
          Returns an iterator of the set of leaf nodes.
 Graph.Node[] getRootArray()
          Returns an array of all root nodes.
 java.util.Iterator getRoots()
          Returns an iterator of the set of root nodes.
 boolean isLeaf(Graph.Node node)
          Checks if the node is a leaf node.
 boolean isRoot(Graph.Node node)
          Checks if the node is a root node.
 void removeLeaf(Graph.Node node)
          Removes a node from the set of leaf nodes.
 void removeRoot(Graph.Node node)
          Removes a node from the set of root nodes.
 
Methods inherited from class de.rwth.graph.Graph
getLabel, getNodes, main, setLabel, sizeEdges, sizeNodes, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

roots

protected java.util.HashSet roots
The set of root nodes.

leafs

protected java.util.HashSet leafs
The set of leaf nodes.
Constructor Detail

RootedGraph

public RootedGraph()
Creates a new RootedGraph without a label.

RootedGraph

public RootedGraph(java.lang.Object label)
Creates a new RootedGraph with a label.
Parameters:
label - the label of the graph.
Method Detail

addRoot

public void addRoot(Graph.Node node)
             throws java.lang.IllegalArgumentException
Adds a node as one of the roots of this graph.
Parameters:
node - the node which should be added. It must be a node in this graph.
Throws:
java.lang.IllegalArgumentException - if the node is not in this graph.

addLeaf

public void addLeaf(Graph.Node node)
             throws java.lang.IllegalArgumentException
Adds a node as one of the leafs of this graph.
Parameters:
node - the node which should be added. It must be a node in this graph.
Throws:
java.lang.IllegalArgumentException - if the node is not in this graph.

removeRoot

public void removeRoot(Graph.Node node)
Removes a node from the set of root nodes.
Parameters:
node - the node which should be removed.

removeLeaf

public void removeLeaf(Graph.Node node)
Removes a node from the set of leaf nodes.
Parameters:
node - the node which should be removed.

getRoots

public java.util.Iterator getRoots()
Returns an iterator of the set of root nodes.
Returns:
an iterator of the set of root nodes.

getLeafs

public java.util.Iterator getLeafs()
Returns an iterator of the set of leaf nodes.
Returns:
an iterator of the set of leaf nodes.

getRootArray

public Graph.Node[] getRootArray()
Returns an array of all root nodes.
Returns:
an array of all root nodes.

getLeafArray

public Graph.Node[] getLeafArray()
Returns an array of all leaf nodes.
Returns:
an array of all leaf nodes.

isRoot

public boolean isRoot(Graph.Node node)
Checks if the node is a root node.
Returns:
true if node is a root node; false otherwise.

isLeaf

public boolean isLeaf(Graph.Node node)
Checks if the node is a leaf node.
Returns:
true if node is a leaf node; false otherwise.