V
- the vertex typeE
- the edge typepublic class DelegateTree<V,E>
extends edu.uci.ics.jung.graph.GraphDecorator<V,E>
implements edu.uci.ics.jung.graph.Tree<V,E>
Tree
that delegates to
a specified instance of DirectedGraph
.Modifier and Type | Field and Description |
---|---|
protected V |
root |
protected java.util.Map<V,java.lang.Integer> |
vertex_depths |
Constructor and Description |
---|
DelegateTree()
Creates an instance.
|
DelegateTree(edu.uci.ics.jung.graph.DirectedGraph<V,E> graph)
Creates a new
DelegateTree which delegates to graph . |
DelegateTree(org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.DirectedGraph<V,E>> graphFactory)
create an instance with passed values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(E edge,
V parent,
V child)
add the passed child node as a child of parent.
|
boolean |
addChild(E edge,
V parent,
V child,
edu.uci.ics.jung.graph.util.EdgeType edgeType)
add the passed child node as a child of parent.
|
boolean |
addEdge(E edge,
java.util.Collection<? extends V> vertices) |
boolean |
addEdge(E e,
V v1,
V v2)
Add an edge to the tree, connecting v1, the parent and v2, the child.
|
boolean |
addEdge(E e,
V v1,
V v2,
edu.uci.ics.jung.graph.util.EdgeType edgeType)
Add an edge to the tree, connecting v1, the parent and v2, the child.
|
boolean |
addVertex(V vertex)
Will set the root of the Tree, only if the Tree is empty and the
root is currently unset.
|
int |
getChildCount(V parent)
get the number of children of the passed parent node
|
java.util.Collection<E> |
getChildEdges(V vertex) |
java.util.Collection<V> |
getChildren(V parent)
get the immediate children nodes of the passed parent
|
int |
getDepth(V v)
computes and returns the depth of the tree from the
root to the passed vertex
|
static <V,E> org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Tree<V,E>> |
getFactory()
Returns a
Factory that creates an instance of this graph type. |
int |
getHeight()
Computes and returns the height of the tree.
|
int |
getIncidentCount(E edge) |
V |
getParent(V child)
get the single parent node of the passed child
|
E |
getParentEdge(V vertex) |
java.util.List<V> |
getPath(V vertex)
Returns an ordered list of the nodes beginning at the root
and ending at
vertex , including all intermediate
nodes. |
V |
getRoot()
getter for the root of the tree
|
java.util.Collection<edu.uci.ics.jung.graph.Tree<V,E>> |
getTrees() |
boolean |
isInternal(V v)
Returns
true if v is neither
a leaf nor the root of this tree. |
boolean |
isLeaf(V v)
Returns
true if the passed node has no
children. |
boolean |
isRoot(V v)
computes whether the passed node is a root node
(has no children)
|
boolean |
removeChild(V orphan)
removes a node from the tree, causing all descendants of
the removed node also to be removed
|
boolean |
removeVertex(V vertex)
remove the passed node, and all nodes that are descendants of the
passed node.
|
void |
setRoot(V root)
sets the root to the passed value, only if the root is
previously unset
|
java.lang.String |
toString() |
addEdge, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getDest, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getEndpoints, getIncidentEdges, getIncidentVertices, getInEdges, getNeighborCount, getNeighbors, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, getVertexCount, getVertices, inDegree, isDest, isIncident, isNeighbor, isPredecessor, isSource, isSuccessor, outDegree, removeEdge
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDest, getEndpoints, getInEdges, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, inDegree, isDest, isPredecessor, isSource, isSuccessor, outDegree
addEdge, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getIncidentEdges, getIncidentVertices, getNeighborCount, getNeighbors, getVertexCount, getVertices, isIncident, isNeighbor, removeEdge
protected V root
protected java.util.Map<V,java.lang.Integer> vertex_depths
public DelegateTree()
public DelegateTree(org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.DirectedGraph<V,E>> graphFactory)
graphFactory
- must create a DirectedGraph to use as a delegatepublic static final <V,E> org.apache.commons.collections4.Factory<edu.uci.ics.jung.graph.Tree<V,E>> getFactory()
Factory
that creates an instance of this graph type.V
- the vertex type for the graph factoryE
- the edge type for the graph factorypublic boolean addEdge(E e, V v1, V v2, edu.uci.ics.jung.graph.util.EdgeType edgeType)
addEdge
in interface edu.uci.ics.jung.graph.Graph<V,E>
addEdge
in class edu.uci.ics.jung.graph.GraphDecorator<V,E>
e
- a unique edge to addv1
- the parent nodev2
- the child nodeedgeType
- should be EdgeType.DIRECTEDGraph.addEdge(java.lang.Object, java.lang.Object, java.lang.Object, edu.uci.ics.jung.graph.util.EdgeType)
public boolean addEdge(E e, V v1, V v2)
addEdge
in interface edu.uci.ics.jung.graph.Graph<V,E>
addEdge
in class edu.uci.ics.jung.graph.GraphDecorator<V,E>
e
- a unique edge to addv1
- the parent nodev2
- the child nodeGraph.addEdge(java.lang.Object, java.lang.Object, java.lang.Object)
public boolean addVertex(V vertex)
addVertex
in interface edu.uci.ics.jung.graph.Hypergraph<V,E>
addVertex
in class edu.uci.ics.jung.graph.GraphDecorator<V,E>
vertex
- the tree root to setjava.lang.UnsupportedOperationException
- if the root was previously setHypergraph.addVertex(java.lang.Object)
public boolean removeVertex(V vertex)
public boolean addChild(E edge, V parent, V child, edu.uci.ics.jung.graph.util.EdgeType edgeType)
edge
- the unique edge to connect the parent and child nodesparent
- the existing parent to attach the child tochild
- the new child to add to the tree as a child of parentedgeType
- must be EdgeType.DIRECTED or the underlying graph may throw an exceptionpublic boolean addChild(E edge, V parent, V child)
edge
- the unique edge to connect the parent and child nodesparent
- the existing parent to attach the child tochild
- the new child to add to the tree as a child of parentpublic int getChildCount(V parent)
public java.util.Collection<V> getChildren(V parent)
public java.util.List<V> getPath(V vertex)
vertex
, including all intermediate
nodes.vertex
- the last node in the path from the rootpublic V getRoot()
public void setRoot(V root)
root
- the initial tree rootpublic boolean removeChild(V orphan)
orphan
- the node to removepublic int getDepth(V v)
public int getHeight()
public boolean isInternal(V v)
true
if v
is neither
a leaf nor the root of this tree.true
if v
is neither
a leaf nor the root of this treepublic boolean isLeaf(V v)
true
if the passed node has no
children.true
if the passed node has no
childrenpublic boolean isRoot(V v)
public int getIncidentCount(E edge)
public java.lang.String toString()
toString
in class java.lang.Object