baseCode.dataStructure.graph
Class DirectedGraph

java.lang.Object
  extended bybaseCode.dataStructure.graph.AbstractGraph
      extended bybaseCode.dataStructure.graph.DirectedGraph
All Implemented Interfaces:
Graph

public class DirectedGraph
extends AbstractGraph

A graph that contains DirectedGraphNodes. It can be cyclic. Small unconnected parts of the graph will be ignored for many operation. Tree traversals start from the root node, which is defined as the node with the most children.

Copyright (c) Columbia University

Version:
$Id: DirectedGraph.java,v 1.8 2004/07/27 03:18:58 pavlidis Exp $
Author:
Paul Pavlidis

Field Summary
 
Fields inherited from class baseCode.dataStructure.graph.AbstractGraph
items
 
Constructor Summary
DirectedGraph()
           
DirectedGraph(java.util.Set nodes)
           
 
Method Summary
 void addChildTo(java.lang.Object key, java.lang.Object newChildKey)
          Add a child to a particular node identified by key; if the node is not in the graph, an exception is thrown.
 void addChildTo(java.lang.Object key, java.lang.Object newChildKey, java.lang.Object newChild)
          Add a child to a particualar node identified by key.
 void addNode(java.lang.Object key, java.lang.Object item)
           
 void addParentTo(java.lang.Object key, java.lang.Object newParentKey)
           
 void addParentTo(java.lang.Object key, java.lang.Object newParentKey, java.lang.Object newParent)
           
 void prune()
          Remove vertices to nodes that aren't in the graph.
 void topoSort()
          Fills in the topoSortOrder for each node.
 java.lang.String toString()
          Shows the tree as a tabbed list.
 javax.swing.JTree treeView()
          Generate a JTree corresponding to this graph.
 
Methods inherited from class baseCode.dataStructure.graph.AbstractGraph
addNode, containsKey, get, getItems, getNodeContents, unmarkAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirectedGraph

public DirectedGraph()

DirectedGraph

public DirectedGraph(java.util.Set nodes)
Parameters:
nodes - Set of DirectedGraphNodes
Method Detail

addNode

public void addNode(java.lang.Object key,
                    java.lang.Object item)
Parameters:
key - Object
item - Object

addChildTo

public void addChildTo(java.lang.Object key,
                       java.lang.Object newChildKey,
                       java.lang.Object newChild)
Add a child to a particualar node identified by key.

Parameters:
key - Object
newChildKey - Object
newChild - Object

addChildTo

public void addChildTo(java.lang.Object key,
                       java.lang.Object newChildKey)
                throws java.lang.IllegalStateException
Add a child to a particular node identified by key; if the node is not in the graph, an exception is thrown.

Parameters:
key - Object
newChildKey - Object
Throws:
java.lang.IllegalStateException - if the graph doesn't contain the child node.

addParentTo

public void addParentTo(java.lang.Object key,
                        java.lang.Object newParentKey,
                        java.lang.Object newParent)
Parameters:
key - Object
newParentKey - Object
newParent - Object

addParentTo

public void addParentTo(java.lang.Object key,
                        java.lang.Object newParentKey)
                 throws java.lang.IllegalStateException
Parameters:
key - Object
newParentKey - Object
Throws:
java.lang.IllegalStateException

toString

public java.lang.String toString()
Shows the tree as a tabbed list. Items that have no parents are shown at the 'highest' level.

Returns:
String

prune

public void prune()
Remove vertices to nodes that aren't in the graph.


topoSort

public void topoSort()
Fills in the topoSortOrder for each node.


treeView

public javax.swing.JTree treeView()
Generate a JTree corresponding to this graph.

Returns:
javax.swing.JTree


Copyright © 2003-2005 Columbia University. All Rights Reserved.