@ThreadSafe public final class DependencyGraph<T> extends Object
| Constructor and Description |
|---|
DependencyGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDependency(T from,
T to)
Add a dependency between two elements
|
void |
clearAll() |
Set<T> |
getDependents(T element)
Return the dependents
|
boolean |
hasDependent(T element)
Check if an element is depended on
|
void |
remove(T element)
Remove element from the graph
|
void |
removeDependency(T from,
T to)
Remove a dependency
|
List<T> |
topologicalSort()
Calculates a topological sort of the graph, in linear time
|
public List<T> topologicalSort() throws CyclicDependencyException
CyclicDependencyException - if cycles are present in the graph and thus no topological sort is possiblepublic void addDependency(T from, T to)
from - From elementto - To elementpublic void removeDependency(T from, T to)
from - From elementto - To elementIllegalArgumentException - if either to or from don't existpublic void clearAll()
public boolean hasDependent(T element)
element - Element stored in the graphIllegalArgumentException - if element is not present in the graphpublic Set<T> getDependents(T element)
element - Element contained in the graphpublic void remove(T element)
element - the elementCopyright © 2021 JBoss by Red Hat. All rights reserved.