V - the vertex typeE - the edge typepublic class DelegateForest<V,E> extends GraphDecorator<V,E> implements Forest<V,E>
Forest that delegates to a specified DirectedGraph
instance.delegate| Constructor and Description |
|---|
DelegateForest()
Creates an instance backed by a new
DirectedSparseGraph instance. |
DelegateForest(DirectedGraph<V,E> delegate)
Creates an instance backed by the input
DirectedGraph. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEdge(E edge,
Collection<? extends V> vertices) |
boolean |
addEdge(E e,
V v1,
V v2,
EdgeType edgeType)
Add an edge to the tree, connecting v1, the parent and v2, the child.
|
void |
addTree(Tree<V,E> tree)
Adds
tree to this graph as an element of this forest. |
boolean |
addVertex(V vertex)
Add vertex as a root of the tree
|
int |
getChildCount(V vertex) |
Collection<E> |
getChildEdges(V vertex) |
Collection<V> |
getChildren(V v) |
int |
getDepth(V v)
computes and returns the depth of the tree from the
root to the passed vertex
|
int |
getHeight()
computes and returns the height of the tree
|
int |
getIncidentCount(E edge) |
V |
getParent(V child) |
E |
getParentEdge(V vertex) |
List<V> |
getPath(V child)
returns an ordered list of the nodes beginning at the root
and ending at the passed child node, including all intermediate
nodes.
|
V |
getRoot() |
Collection<V> |
getRoots() |
Collection<Tree<V,E>> |
getTrees() |
boolean |
isInternal(V v) |
boolean |
isLeaf(V v) |
boolean |
isRoot(V v) |
boolean |
removeChild(V orphan)
removes a node from the tree, causing all descendants of
the removed node also to be removed
|
boolean |
removeEdge(E edge)
Removes
edge from this tree, and the subtree rooted
at the child vertex incident to edge. |
boolean |
removeEdge(E edge,
boolean remove_subtree)
Removes
edge from this tree. |
boolean |
removeVertex(V vertex)
Removes
vertex from this tree, and the subtree
rooted at vertex. |
boolean |
removeVertex(V vertex,
boolean remove_subtrees)
Removes
vertex from this tree. |
void |
setRoot(V root)
adds root as a root of the tree
|
addEdge, 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, outDegreeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddEdge, getDest, getEndpoints, getInEdges, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, inDegree, isDest, isPredecessor, isSource, isSuccessor, outDegreeaddEdge, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getIncidentEdges, getIncidentVertices, getNeighborCount, getNeighbors, getVertexCount, getVertices, isIncident, isNeighborpublic DelegateForest()
DirectedSparseGraph instance.public DelegateForest(DirectedGraph<V,E> delegate)
DirectedGraph.delegate - the graph to which operations will be delegatedpublic boolean addEdge(E e, V v1, V v2, EdgeType edgeType)
addEdge in interface Graph<V,E>addEdge in class 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 addVertex(V vertex)
addVertex in interface Hypergraph<V,E>addVertex in class GraphDecorator<V,E>vertex - the tree root to addHypergraph.addVertex(java.lang.Object)public boolean removeEdge(E edge)
edge from this tree, and the subtree rooted
at the child vertex incident to edge.
(The subtree is removed to ensure that the tree in which the edge
was found is still a tree rather than a forest. To change this
behavior so that theremoveEdge in interface Hypergraph<V,E>removeEdge in class GraphDecorator<V,E>edge - the edge to removetrue iff the tree was modifiedHypergraph.removeEdge(java.lang.Object)public boolean removeEdge(E edge, boolean remove_subtree)
edge from this tree.
If remove_subtree is true, removes
the subtree rooted at the child vertex incident to edge.
Otherwise, leaves the subtree intact as a new component tree of this
forest.edge - the edge to removeremove_subtree - if true, remove the subtreetrue iff the tree was modifiedpublic boolean removeVertex(V vertex)
vertex from this tree, and the subtree
rooted at vertex.removeVertex in interface Hypergraph<V,E>removeVertex in class GraphDecorator<V,E>vertex - the vertex to removetrue iff the tree was modifiedHypergraph.removeVertex(java.lang.Object)public boolean removeVertex(V vertex, boolean remove_subtrees)
vertex from this tree.
If remove_subtrees is true, removes
the subtrees rooted at the children of vertex.
Otherwise, leaves these subtrees intact as new component trees of this
forest.vertex - the vertex to removeremove_subtrees - if true, remove the subtrees
rooted at vertex's childrentrue iff the tree was modifiedpublic List<V> getPath(V child)
child - 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)
v - the node who's depth is computedpublic int getHeight()
public boolean isInternal(V v)
v - the vertex to testtrue if v is neither a leaf
nor a rootpublic boolean isLeaf(V v)
v - the vertex to testtrue if v has no child nodes.public Collection<V> getChildren(V v)
getChildren in interface Forest<V,E>v - the vertex whose children are to be returnedv.public boolean isRoot(V v)
v - the vertex to testtrue if v has no parent node.public int getIncidentCount(E edge)
getIncidentCount in interface Hypergraph<V,E>getIncidentCount in class GraphDecorator<V,E>public boolean addEdge(E edge, Collection<? extends V> vertices)
addEdge in interface Hypergraph<V,E>addEdge in class GraphDecorator<V,E>public Collection<V> getRoots()
Collection.public void addTree(Tree<V,E> tree)
tree to this graph as an element of this forest.tree - the tree to add to this forest as a componentpublic int getChildCount(V vertex)
getChildCount in interface Forest<V,E>public Collection<E> getChildEdges(V vertex)
getChildEdges in interface Forest<V,E>Copyright © 2016. All rights reserved.