T
- type of the nodes' labelspublic class Digraph<T> extends java.lang.Object implements java.lang.Iterable<DigraphNode<T>>
Modifier and Type | Field and Description |
---|---|
private java.util.Collection<DigraphNode<T>> |
nodes
the grsph's nodes
|
private boolean |
uniq
if uniq is true there can only be one single node labelled with the same instance of T
|
Modifier and Type | Method and Description |
---|---|
DigraphNode<T> |
addNode(T val) |
java.util.Collection<DigraphNode<T>> |
getLeafs()
leaves are nodes with an outdegree of 0
|
java.util.Collection<DigraphNode<T>> |
getRoots()
roots are nodes with an indegree of 0
|
java.util.Collection<T> |
getValues() |
java.util.Iterator<DigraphNode<T>> |
iterator() |
int |
numberOfEdges() |
int |
numberOfNodes() |
private void |
printNode(java.io.PrintStream os,
DigraphNode<T> node,
int tab)
prints a node
|
void |
printTree(java.io.OutputStream os,
DigraphNode<T> root)
prints a tree
|
void |
printTrees(java.io.OutputStream os)
prints a tree for every root node in the graph
|
private java.util.Collection<DigraphNode<T>> nodes
private final boolean uniq
public DigraphNode<T> addNode(T val)
public int numberOfNodes()
public int numberOfEdges()
public java.util.Collection<DigraphNode<T>> getLeafs()
public java.util.Collection<DigraphNode<T>> getRoots()
public java.util.Collection<T> getValues()
public void printTrees(java.io.OutputStream os)
os
- public void printTree(java.io.OutputStream os, DigraphNode<T> root)
os
- root
- the root of the treeprivate void printNode(java.io.PrintStream os, DigraphNode<T> node, int tab)
os
- node
- to be printedtab
- indention levelpublic java.util.Iterator<DigraphNode<T>> iterator()
iterator
in interface java.lang.Iterable<DigraphNode<T>>