public class DirectedGraph<E> extends Object
Constructor and Description |
---|
DirectedGraph()
Default constructor
|
DirectedGraph(Collection<E> elements)
Constructor that adds a number of elements as initial nodes
|
Modifier and Type | Method and Description |
---|---|
void |
add(E element)
Add an element as node
|
void |
addOrder(E source,
E target)
Add an edge between two elements
|
boolean |
contains(E element)
Determine whether an element in contained in the directed graph
|
Set<E> |
getElements()
Getter for elements
|
Set<E> |
getIncoming(E element)
Get the elements which are source of incoming edges
|
E |
getNoIncomingElement()
Return all elements which do not have incoming edges
|
List<E> |
getOrdering()
Calculate a topological sorting of the elements in the directed graph.
|
Set<E> |
getOutgoing(E element)
Get the elements which are target of outgoing edges
|
boolean |
isEmpty()
Return whether the graph is empty
|
void |
remove(E element)
Remove an element as node
|
void |
removeOrder(E source,
E target)
Remove an edge between two elements
|
public DirectedGraph()
public DirectedGraph(Collection<E> elements)
elements
- Initial nodespublic void add(E element)
element
- Elementpublic void remove(E element)
element
- Elementpublic void addOrder(E source, E target)
source
- Source elementtarget
- Target elementpublic void removeOrder(E source, E target)
source
- Source elementtarget
- Target elementpublic Set<E> getIncoming(E element)
element
- Elementpublic Set<E> getOutgoing(E element)
element
- public boolean isEmpty()
public E getNoIncomingElement()
public boolean contains(E element)
element
- Copyright © 2020. All rights reserved.