Class DirectedGraphNode<K,V>
java.lang.Object
ubic.basecode.dataStructure.Visitable
ubic.basecode.dataStructure.graph.AbstractGraphNode<K,V>
ubic.basecode.dataStructure.graph.DirectedGraphNode<K,V>
- All Implemented Interfaces:
Comparable<DirectedGraphNode<K,,V>> GraphNode<K,V>
public class DirectedGraphNode<K,V>
extends AbstractGraphNode<K,V>
implements Comparable<DirectedGraphNode<K,V>>
A graph node that has the concept of parents and children. Keys can be anything, but probably Strings or Integers.
- Author:
- Paul Pavlidis
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intFields inherited from class ubic.basecode.dataStructure.graph.AbstractGraphNode
item, key, visited -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclone()Makes a copy of this node.intcompareTo(DirectedGraphNode<K, V> o) Uses the topological sort order.Get all the children of this node, recursively.Get all the parents of this node, recursively.intGet the subgraph starting from this node, including this node.Get the immediate children of this node.getGraph()Get the immediate parents of this node.intbooleanCheck to see if this node has a particular immediate child.booleanCheck to see if this node has a particular immediate parent.intinDegree()booleanisLeaf()intintvoidprune()Remove connections that are to nodes not contained in this graphvoidsetGraph(DirectedGraph<K, V> graph) voidsetTopoSortOrder(int i) toString()
-
Field Details
-
children
-
parents
-
topoSortOrder
protected int topoSortOrder
-
-
Constructor Details
-
DirectedGraphNode
- Parameters:
key- Objectvalue- Objectgraph- Graph
-
-
Method Details
-
addChild
- Parameters:
newChildKey- Object
-
addParent
- Parameters:
newParentKey- Object
-
clone
Makes a copy of this node. It does not make a deep copy of the contents. This should be used when making subgraphs. -
compareTo
Uses the topological sort order.- Specified by:
compareToin interfaceComparable<K>- Parameters:
o- Object- Returns:
- int
-
getAllChildNodes
Get all the children of this node, recursively. -
getAllParentNodes
Get all the parents of this node, recursively.- Returns:
-
getChildCount
public int getChildCount()- Returns:
- int how many children this node has, determined recursively.
-
getChildGraph
Get the subgraph starting from this node, including this node.- Returns:
- Graph
-
getChildKeys
- Returns:
- Object
-
getChildNodes
Get the immediate children of this node. References to the DirectedGraphNodes are given, as opposed to key values.- Returns:
- Set containing the child nodes of this node.
-
getGraph
-
getParentKeys
- Returns:
- Object
-
getParentNodes
Get the immediate parents of this node. References to the DirectedGraphNodes are given, as opposed to key values.- Returns:
- Set
-
getTopoSortOrder
public int getTopoSortOrder()- Returns:
- int
-
hasChild
Check to see if this node has a particular immediate child.- Parameters:
j- Object- Returns:
- boolean
-
hasParent
Check to see if this node has a particular immediate parent.- Parameters:
j- Object- Returns:
- boolean
-
inDegree
public int inDegree()- Returns:
- int number of immediate parents this node has.
-
isLeaf
public boolean isLeaf()- Returns:
-
numParents
public int numParents()- Returns:
- int how many parents this node has, determined recursively.
-
outDegree
public int outDegree()- Returns:
- int number of immediate children this node has.
-
prune
public void prune()Remove connections that are to nodes not contained in this graph -
setGraph
-
setTopoSortOrder
public void setTopoSortOrder(int i) - Parameters:
i- int
-
toString
- Overrides:
toStringin classAbstractGraphNode<K,V>
-