digraphs
Class DigraphNode

java.lang.Object
  extended by digraphs.DigraphNode
Direct Known Subclasses:
DigraphNodeLabeled

public class DigraphNode
extends java.lang.Object

A class for representing nodes of directed graphs.

Author:
James A. Mason

Constructor Summary
DigraphNode()
          Initializes a new DigraphNode with a default estimated number of in-edges and of out-edges per node.
DigraphNode(int edgesPerNode)
          Initializes a new DigraphNode with an estimated number of in-edges and of out-edges per node.
 
Method Summary
 DigraphEdge addInEdge(DigraphEdge aDigraphEdge)
          Adds given DigraphEdge to the list of inEdges, after checking that the DigraphEdge is connected TO the receiver.
 DigraphEdge addOutEdge(DigraphEdge aDigraphEdge)
          Adds given DigraphEdge to the list of outEdges, after checking that the DigraphEdge is connected FROM the receiver.
 java.util.ArrayList<DigraphNode> ancestors()
          Returns an ArrayList of all DigraphNodes from which the receiver can be reached by traversal of one or more edges out.
 java.util.HashSet<DigraphNode> ancestors(java.util.HashSet<DigraphNode> aSet)
          Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but from which the receiver is reachable by traversal of one or more edges out.
 java.util.ArrayList<DigraphNode> connectedNodes()
          Returns an ArrayList of all DigraphNodes from which the receiver can be reached by traversal of one or more edges out without regard to direction.
 java.util.HashSet<DigraphNode> connectedNodes(java.util.HashSet<DigraphNode> aSet)
          Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but from which the receiver is reachable by traversal of one or more edges without regard to edge direction.
 java.util.ArrayList<DigraphNode> descendants()
          Returns an ArrayList of all DigraphNodes that are reachable from the receiver by traversal of one or more edges out.
 java.util.HashSet<DigraphNode> descendants(java.util.HashSet<DigraphNode> aSet)
          Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but are reachable from the receiver by traversal of one or more edges out.
 java.util.ArrayList<DigraphEdge> getInEdges()
          Returns an ArrayList of the DigraphEdges that enter the DigraphNode.
 java.util.ArrayList<DigraphEdge> getOutEdges()
          Returns an ArrayList of the DigraphEdges that leave the DigraphNode.
 int inDegree()
          Returns the number of DigraphEdges that enter the DigraphNode.
 java.util.ArrayList<DigraphNode> neighboursIn()
          Returns an ArrayList of the DigraphNodes at the beginnings of all incoming edges.
 java.util.ArrayList<DigraphNode> neighboursOut()
          Returns an ArrayList of the DigraphNodes at the ends of all outgoing edges.
 int outDegree()
          Returns the number of DigraphEdges that leave the DigraphNode.
 DigraphEdge removeInEdge(DigraphEdge aDigraphEdge)
          Removes given DigraphEdge from the list of inEdges, after checking that the DigraphEdge is connected TO the receiver.
 DigraphEdge removeOutEdge(DigraphEdge aDigraphEdge)
          Removes given DigraphEdge from the list of outEdges, after checking that the DigraphEdge is connected FROM the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigraphNode

public DigraphNode()
Initializes a new DigraphNode with a default estimated number of in-edges and of out-edges per node.


DigraphNode

public DigraphNode(int edgesPerNode)
Initializes a new DigraphNode with an estimated number of in-edges and of out-edges per node.

Method Detail

addInEdge

public DigraphEdge addInEdge(DigraphEdge aDigraphEdge)
Adds given DigraphEdge to the list of inEdges, after checking that the DigraphEdge is connected TO the receiver.

Parameters:
aDigraphEdge - the DigraphEdge to be added to the node.
Returns:
the DigraphEdge if successful; null if the edge does not enter the node or has already been included as an incoming edge

addOutEdge

public DigraphEdge addOutEdge(DigraphEdge aDigraphEdge)
Adds given DigraphEdge to the list of outEdges, after checking that the DigraphEdge is connected FROM the receiver.

Parameters:
aDigraphEdge - the DigraphEdge to be added to the node.
Returns:
the DigraphEdge if successful; null if the edge does not leave the node or has already been included as an outgoing edge

ancestors

public java.util.ArrayList<DigraphNode> ancestors()
Returns an ArrayList of all DigraphNodes from which the receiver can be reached by traversal of one or more edges out.


ancestors

public java.util.HashSet<DigraphNode> ancestors(java.util.HashSet<DigraphNode> aSet)
Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but from which the receiver is reachable by traversal of one or more edges out. Returns the result of updating aSet.

Parameters:
aSet - a HashSet of DigraphNodes.
Returns:
the updated HashSet of DigraphNodes.

connectedNodes

public java.util.ArrayList<DigraphNode> connectedNodes()
Returns an ArrayList of all DigraphNodes from which the receiver can be reached by traversal of one or more edges out without regard to direction.


connectedNodes

public java.util.HashSet<DigraphNode> connectedNodes(java.util.HashSet<DigraphNode> aSet)
Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but from which the receiver is reachable by traversal of one or more edges without regard to edge direction. Returns the result of updating aSet.

Parameters:
aSet - a HashSet of DigraphNodes.
Returns:
the updated HashSet of DigraphNodes.

descendants

public java.util.ArrayList<DigraphNode> descendants()
Returns an ArrayList of all DigraphNodes that are reachable from the receiver by traversal of one or more edges out.


descendants

public java.util.HashSet<DigraphNode> descendants(java.util.HashSet<DigraphNode> aSet)
Adds to the HashSet aSet all DigraphNodes that are NOT already in aSet but are reachable from the receiver by traversal of one or more edges out. Returns the result of updating aSet.

Parameters:
aSet - a HashSet of DigraphNodes.
Returns:
the updated HashSet of DigraphNodes.

getInEdges

public java.util.ArrayList<DigraphEdge> getInEdges()
Returns an ArrayList of the DigraphEdges that enter the DigraphNode.


getOutEdges

public java.util.ArrayList<DigraphEdge> getOutEdges()
Returns an ArrayList of the DigraphEdges that leave the DigraphNode.


inDegree

public int inDegree()
Returns the number of DigraphEdges that enter the DigraphNode.


neighboursIn

public java.util.ArrayList<DigraphNode> neighboursIn()
Returns an ArrayList of the DigraphNodes at the beginnings of all incoming edges. (Some may be identical.)


neighboursOut

public java.util.ArrayList<DigraphNode> neighboursOut()
Returns an ArrayList of the DigraphNodes at the ends of all outgoing edges. (Some may be identical.)


outDegree

public int outDegree()
Returns the number of DigraphEdges that leave the DigraphNode.


removeInEdge

public DigraphEdge removeInEdge(DigraphEdge aDigraphEdge)
Removes given DigraphEdge from the list of inEdges, after checking that the DigraphEdge is connected TO the receiver.

Parameters:
aDigraphEdge - the DigraphEdge to be removed from the node.
Returns:
the DigraphEdge if successful; null if the edge does not enter the node

removeOutEdge

public DigraphEdge removeOutEdge(DigraphEdge aDigraphEdge)
Removes given DigraphEdge from the list of outEdges, after checking that the DigraphEdge is connected FROM the receiver.

Parameters:
aDigraphEdge - the DigraphEdge to be removed from the node.
Returns:
the DigraphEdge if successful; null if the edge does not leave the node