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 int
Fields inherited from class ubic.basecode.dataStructure.graph.AbstractGraphNode
item, key, visited
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
clone()
Makes a copy of this node.int
compareTo
(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.int
Get the subgraph starting from this node, including this node.Get the immediate children of this node.getGraph()
Get the immediate parents of this node.int
boolean
Check to see if this node has a particular immediate child.boolean
Check to see if this node has a particular immediate parent.int
inDegree()
boolean
isLeaf()
int
int
void
prune()
Remove connections that are to nodes not contained in this graphvoid
setGraph
(DirectedGraph<K, V> graph) void
setTopoSortOrder
(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:
compareTo
in 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:
toString
in classAbstractGraphNode<K,
V>
-