public class DirectedGraph<E extends Comparable<E>> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DirectedGraph.Node<E extends Comparable<E>>
Represents a node of in a graph
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<E,DirectedGraph.Node<E>> |
nodes
Holds the nodes
|
| Constructor and Description |
|---|
DirectedGraph()
Constructor for subclasses
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLink(E parent,
E child)
Adds a link from a parent to a child
|
boolean |
contains(E label)
True if that node exists
|
static DirectedGraph<String> |
create(File file,
Pattern pattern)
Constructs a directed graph from a File.
|
DirectedGraph.Node<E> |
get(E label)
Returns the node with the given label (or null)
|
DirectedGraph.Node<E> |
getOrMake(E label)
Returns or creates a node
|
Collection<E> |
labels()
Computes the set of labels
|
SortedSet<DirectedGraph.Node<E>> |
leaves()
Computes the nodes that have no leaves
|
void |
makeClosure()
Adds all transitive links
|
Collection<DirectedGraph.Node<E>> |
nodes()
Returns all nodes
|
int |
numNodes()
Returns the number of nodes
|
SortedSet<DirectedGraph.Node<E>> |
roots()
Computes the nodes that have no parents
|
String |
toString() |
protected Map<E extends Comparable<E>,DirectedGraph.Node<E extends Comparable<E>>> nodes
public DirectedGraph.Node<E> getOrMake(E label)
public static DirectedGraph<String> create(File file, Pattern pattern) throws IOException
IOExceptionpublic SortedSet<DirectedGraph.Node<E>> roots()
public SortedSet<DirectedGraph.Node<E>> leaves()
public Collection<DirectedGraph.Node<E>> nodes()
public int numNodes()
public Collection<E> labels()
public DirectedGraph.Node<E> get(E label)
public boolean contains(E label)
public void makeClosure()
Copyright © 2018. All rights reserved.