Graph
A Graph is an unordered collection of vertices, along with the successor-predecessor relationships between them. From the Graph's viewpoint, the vertices are merely mementos that support equals and hashCode. Edges are not explicitly represented, but instead are a consequence of how the outEdges and inEdges are populated.
Graph is not synchronized.
Author
Mark van Gulik
Parameters
The vertex type with which to parameterize the Graph.
Constructors
Types
A GraphPreconditionFailure is thrown whenever a precondition of a graph manipulation operation does not hold. The preconditions are described in the JavaDoc comment for each operation.
Functions
Add a collection of vertices to the graph. Fail if any vertex is already present in the graph, or if it occurs multiple times in the given collection. The vertices initially have no edges within this graph.
Create a subgraph containing each of the provided vertices and all of their ancestors.
If the given vertex is present in the graph, remove its incoming and outgoing edges, then the vertex itself. If the given vertex is not in the graph, do nothing.
Remove an edge from the graph, from the source vertex to the target vertex. Fail if either vertex is not present in the graph. If there is no such edge in the graph then do nothing.
Remove all edges from the graph which originate at the given vertex. Fail if the vertex is not present in the graph.
Remove all edges from the graph which terminate at the given vertex. Fail if the vertex is not present in the graph.
Remove a vertex from the graph, removing any connected edges. Do nothing if the vertex is not in the graph.
Add an edge to the graph from the source vertex to the target vertex. Fail if either vertex is not present in the graph. If the graph already contains an edge from the source vertex to the target vertex then do nothing.
Determine if the graph contains an edge from the source vertex to the target vertex. Fail if either vertex is not present in the graph.
Determine if the given vertex is in the graph.
Add a vertex to the graph if it's not already present. If the vertex is already present, do nothing. If the vertex is added it initially has no edges within this graph.
Visit the vertices in DAG order. The action is invoked for each vertex, also passing a completion action to invoke when that vertex visit is considered complete, allowing successors for which all predecessors have completed to be visited.
Visit the vertices in DAG order. The action is invoked for each vertex, also passing a completion action to invoke when that vertex visit is considered complete, allowing successors for which all predecessors have completed to be visited.
Answer the set of predecessors of the specified vertex. Fail if the vertex is not present in the graph.
Remove an edge from the graph, from the source vertex to the target vertex. Fail if either vertex is not present in the graph, or if there is no such edge in the graph.
Remove a vertex from the graph, failing if it has any connected edges. Fail if the vertex is not present in the graph.
Answer the set of successors of the specified vertex. Fail if the vertex is not present in the graph.
Given an acyclic graph, produce a subgraph that excludes any edges for which there is another path connecting those edges in the original graph.