Class GraphNode

java.lang.Object
  |
  +--GraphNode

public class GraphNode
extends java.lang.Object

GraphNode is used to model the node in a graph. It holds handles to the course object (with its own prerequisite set) and a children set. The children set contains all those course ID's that this node would point to in a graph. It also holds the integer inDegrees.


Constructor Summary
GraphNode(Course c)
          Create a GraphNode with a Course object.
 
Method Summary
 void addChild(java.lang.String courseID)
          add a child to this GraphNode -- this graph node will have this child on its adjaceny list.
 void decDegrees()
          subtract one from the inDegrees field
 java.util.Iterator getChildren()
          return an iterator on the cildren (adjacency list)
 Course getCourse()
           
 void incDegrees()
          add one to the inDegrees field
 boolean inDegreeZero()
          Is the inDegree field zero?
 boolean isRemoved()
          check if node is considered in the graph
 void remove()
          set inDegrees field to -1 to signal node no longer considered in the graph
 void setIndegreesZero()
          Force inDegree to 0
 java.lang.String toString()
          convert the GraphNode to a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphNode

public GraphNode(Course c)
Create a GraphNode with a Course object. Build a TreeSet for the adjacency list. Set inDegrees to the number of prerequisties in the course object.
Parameters:
c - the course to add to the graph
Method Detail

getCourse

public Course getCourse()
Returns:
a reference to the course

incDegrees

public void incDegrees()
add one to the inDegrees field

decDegrees

public void decDegrees()
subtract one from the inDegrees field

remove

public void remove()
set inDegrees field to -1 to signal node no longer considered in the graph

setIndegreesZero

public void setIndegreesZero()
Force inDegree to 0

inDegreeZero

public boolean inDegreeZero()
Is the inDegree field zero?

isRemoved

public boolean isRemoved()
check if node is considered in the graph

addChild

public void addChild(java.lang.String courseID)
add a child to this GraphNode -- this graph node will have this child on its adjaceny list.

getChildren

public java.util.Iterator getChildren()
return an iterator on the cildren (adjacency list)

toString

public java.lang.String toString()
convert the GraphNode to a String
Overrides:
toString in class java.lang.Object