| Constructor and Description |
|---|
SparseTree(V root)
Construct a tree with a root.
|
| Modifier and Type | Method and Description |
|---|---|
SparseTree<V> |
addEdge(Arc<V> e)
Add an edge to the tree, connecting v1, the parent and v2..., the children.
|
SparseTree<V> |
addVertex(V v)
Adds a vertex to this graph.
|
Set<V> |
children(V v)
Gets the set of all children of this vertex.
|
int |
depth(V v)
Gets the (unweighted) distance of a vertex from the root of the vertex.
|
Set<Arc<V>> |
edges()
Gets the set of all edges in this graph.
|
Set<Arc<V>> |
edges(V v)
Gets the set of all edges associated with a vertex in this graph.
|
int |
height()
Gets the maximum depth in this tree.
|
Set<Arc<V>> |
incomingArcs(V v)
Gets the set of all incoming arcs associated with a vertex in this graph.
|
Set<Arc<V>> |
outgoingArcs(V v)
Gets the set of all outgoing arcs associated with a vertex in this graph.
|
V |
parent(V v)
Gets the unique parent of a vertex.
|
Set<V> |
parents(V v)
Gets the set of all parents of this vertex.
|
SparseTree<V> |
removeEdge(Arc<V> e)
Removes an edge from this graph.
|
SparseTree<V> |
removeVertex(V v)
Removes a vertex from this graph.
|
V |
root()
Gets the root of this tree.
|
RootedTree<V,Arc<V>> |
rotate(V v)
This method re-pivots the tree with a new root vertex.
|
RootedTree<V,Arc<V>> |
subTree(V v)
Gets a sub-tree starting from a vertex.
|
int |
topologicalOrder(V v)
Get the topological order of a vertex.
|
Set<V> |
vertices()
Gets the set of all vertices in this graph.
|
public SparseTree(V root)
root - the tree rootpublic V root()
RootedTreeroot in interface RootedTree<V,Arc<V>>public int depth(V v)
RootedTreedepth in interface RootedTree<V,Arc<V>>v - the vertex whose depth is to be computedpublic int height()
RootedTreeheight in interface RootedTree<V,Arc<V>>public Set<V> vertices()
Graphpublic Set<Arc<V>> edges()
Graphpublic Set<Arc<V>> edges(V v)
Graphpublic SparseTree<V> addVertex(V v)
Graphv is already in the graph.public SparseTree<V> addEdge(Arc<V> e)
public SparseTree<V> removeVertex(V v)
Graphv is not in the graph.
The edges associated with this vertex are also removed.removeVertex in interface Graph<V,Arc<V>>v - the vertex to be removedpublic SparseTree<V> removeEdge(Arc<V> e)
Graphe is not in the graph.
The vertices associated with the edge is not removed.removeEdge in interface Graph<V,Arc<V>>e - the edge to be removedpublic V parent(V v)
Treepublic RootedTree<V,Arc<V>> subTree(V v)
RootedTreesubTree in interface RootedTree<V,Arc<V>>v - the root of the sub-treepublic RootedTree<V,Arc<V>> rotate(V v)
v - the new rootpublic int topologicalOrder(V v)
DAGraphtopologicalOrder in interface DAGraph<V,Arc<V>>v - a vertexpublic Set<Arc<V>> outgoingArcs(V v)
DiGraphoutgoingArcs in interface DiGraph<V,Arc<V>>v - a vertexpublic Set<Arc<V>> incomingArcs(V v)
DiGraphincomingArcs in interface DiGraph<V,Arc<V>>v - a vertexpublic Set<V> parents(V v)
DiGraphCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.