T - the payload of each node.public class DirectedAcyclicGraph<T> extends Object
| Constructor and Description |
|---|
DirectedAcyclicGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(T payload,
List<T> parents)
Adds a node to the DAG, that takes the given payload and depends on the specified parents.
|
boolean |
contains(T payload) |
void |
deleteLeaf(T payload)
Deletes a leaf DAG node that carries the given payload.
|
List<T> |
getAllInTopologicalOrder() |
List<T> |
getChildren(T payload) |
List<T> |
getParents(T payload) |
List<T> |
getRoots() |
boolean |
isRoot(T payload) |
List<T> |
sortTopologically(Set<T> payloads)
Sorts a given set of payloads topologically based on the DAG.
|
public void add(T payload, List<T> parents)
payload - the payloadparents - the parents of the created nodepublic void deleteLeaf(T payload)
payload - the payload of the node to deletepublic boolean contains(T payload)
public List<T> getChildren(T payload)
public List<T> getParents(T payload)
public boolean isRoot(T payload)
public List<T> sortTopologically(Set<T> payloads)
payloads - the set of input payloadsCopyright © 2015. All Rights Reserved.