Class DirectedGraph<T>
java.lang.Object
org.apache.struts2.config.providers.DirectedGraph<T>
- All Implemented Interfaces:
- Iterable<T>
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidGiven a start node, and a destination, adds an arc from the start node to the destination.booleanAdds a new node to the graph.booleanedgeExists(T start, T end) Given two nodes in the graph, returns whether there is an edge from the first node to the second node.Given a node in the graph, returns an immutable view of the edges leaving that node as a set of endpoints.booleanisEmpty()Returns whether the graph is empty.iterator()Returns an iterator that can traverse the nodes in the graph.voidremoveEdge(T start, T dest) Removes the edge from start to dest from the graph.intsize()Returns the number of nodes in the graph.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
DirectedGraphpublic DirectedGraph()
 
- 
- 
Method Details- 
addNodeAdds a new node to the graph. If the node already exists, this function is a no-op.- Parameters:
- node- The node to add.
- Returns:
- Whether or not the node was added.
 
- 
addEdgeGiven a start node, and a destination, adds an arc from the start node to the destination. If an arc already exists, this operation is a no-op. If either endpoint does not exist in the graph, throws a NoSuchElementException.- Parameters:
- start- The start node.
- dest- The destination node.
- Throws:
- NoSuchElementException- If either the start or destination nodes do not exist.
 
- 
removeEdgeRemoves the edge from start to dest from the graph. If the edge does not exist, this operation is a no-op. If either endpoint does not exist, this throws a NoSuchElementException.- Parameters:
- start- The start node.
- dest- The destination node.
- Throws:
- NoSuchElementException- If either node is not in the graph.
 
- 
edgeExistsGiven two nodes in the graph, returns whether there is an edge from the first node to the second node. If either node does not exist in the graph, throws a NoSuchElementException.- Parameters:
- start- The start node.
- end- The destination node.
- Returns:
- Whether there is an edge from start to end.
- Throws:
- NoSuchElementException- If either endpoint does not exist.
 
- 
edgesFromGiven a node in the graph, returns an immutable view of the edges leaving that node as a set of endpoints.- Parameters:
- node- The node whose edges should be queried.
- Returns:
- An immutable view of the edges leaving that node.
- Throws:
- NoSuchElementException- If the node does not exist.
 
- 
iteratorReturns an iterator that can traverse the nodes in the graph.
- 
sizepublic int size()Returns the number of nodes in the graph.- Returns:
- The number of nodes in the graph.
 
- 
isEmptypublic boolean isEmpty()Returns whether the graph is empty.- Returns:
- Whether the graph is empty.
 
 
-