public final class Vertex<T> extends Object implements Comparable<Vertex<T>>
Constructor and Description |
---|
Vertex(String name,
T node)
A vertex wraps a node, which can be anything.
|
Vertex(T node)
A vertex wraps a node, which can be anything.
|
Modifier and Type | Method and Description |
---|---|
void |
addDependency(Vertex<T> v)
Add a dependecy to this Vertex.
|
int |
compareTo(Vertex<T> o)
Used in the sort algorithm to sort all the Vertices so that they respect
the ordinal they were given during the topological sort.
|
List<Vertex<T>> |
getDependencies()
Get the list of dependencies.
|
String |
getName()
Returns the name of the Vertex.
|
T |
getNode()
Get the wrapped node that this Vertex represents.
|
int |
getOrder()
Get the ordinal for this vertex.
|
void |
reset()
Reset the Vertex so that all the flags and runtime states are set back
to the original values.
|
void |
resolveOrder()
Recurse through the tree from this vertex assigning an order to each
and at the same time checking for any cyclic dependencies.
|
public Vertex(T node)
node
- The wrapped node.public void reset()
public String getName()
public T getNode()
public void addDependency(Vertex<T> v)
v
- The vertex we depend on.public void resolveOrder() throws CyclicDependencyException
CyclicDependencyException
- If a cyclic dependency is discovered.public List<Vertex<T>> getDependencies()
public int compareTo(Vertex<T> o)
compareTo
in interface Comparable<Vertex<T>>
o
- The other Vertex to compare withpublic int getOrder()
Copyright © 2016 The Apache Software Foundation. All Rights Reserved.