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()
RootedTree
root
in interface RootedTree<V,Arc<V>>
public int depth(V v)
RootedTree
depth
in interface RootedTree<V,Arc<V>>
v
- the vertex whose depth is to be computedpublic int height()
RootedTree
height
in interface RootedTree<V,Arc<V>>
public Set<V> vertices()
Graph
public Set<Arc<V>> edges()
Graph
public Set<Arc<V>> edges(V v)
Graph
public SparseTree<V> addVertex(V v)
Graph
v
is already in the graph.public SparseTree<V> addEdge(Arc<V> e)
public SparseTree<V> removeVertex(V v)
Graph
v
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)
Graph
e
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)
Tree
public RootedTree<V,Arc<V>> subTree(V v)
RootedTree
subTree
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)
DAGraph
topologicalOrder
in interface DAGraph<V,Arc<V>>
v
- a vertexpublic Set<Arc<V>> outgoingArcs(V v)
DiGraph
outgoingArcs
in interface DiGraph<V,Arc<V>>
v
- a vertexpublic Set<Arc<V>> incomingArcs(V v)
DiGraph
incomingArcs
in interface DiGraph<V,Arc<V>>
v
- a vertexpublic Set<V> parents(V v)
DiGraph
Copyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.