public final class DependencyGraph
extends java.lang.Object
A DependencyGraph
could be used to serialise tree structures regarding the dependencies. The tree will
be transformed in a linear structure (List).
A referenced node will always appear prior to the referencing node. Example:
A | ------------- | | | B C D | Ewill be transformed to E,B,D,C,A oder B,E,D,C,A.
The order of the nodes depends on the order of the defintion via addVertex()
and addEdge()
.
Modifier and Type | Class and Description |
---|---|
static class |
DependencyGraph.Edge
Internal representation of an edge.
|
Constructor and Description |
---|
DependencyGraph()
Creates a new instance of type DependencyGraph.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(java.lang.Object parent,
java.lang.Object child)
Adds an edge to the dependency graph.
|
void |
addVertex(java.lang.Object vertex)
Adds a vertex to the dependency graph.
|
java.util.List |
calculateOrder()
Computers the order of all the nodes.
|
boolean |
containsVertex(java.lang.Object vertex)
Returns
true , if the given vertex has already been added to the DependencyGraph. |
boolean |
isClosed()
Returns
true , if the graph is closed. |
public DependencyGraph()
public void addVertex(java.lang.Object vertex)
vertex
- the vertex that will be added.public boolean containsVertex(java.lang.Object vertex)
true
, if the given vertex has already been added to the DependencyGraph.vertex
- the vertextrue
, if the given vertex has already been added to the DependencyGraph, otherwise
false
.public void addEdge(java.lang.Object parent, java.lang.Object child)
parent
- the parent nodechild
- the child nodepublic boolean isClosed()
true
, if the graph is closed.true
, if the graph is closed.public java.util.List calculateOrder() throws CyclicDependencyException
CyclicDependencyException
- thrown, if the graph structure contains a cycle.