Class DirectedGraph<D>
java.lang.Object
org.spongepowered.collections.graph.DirectedGraph<D>
@DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class)
public class DirectedGraph<@NonNull D>
extends Object
A directed graph type for performing graph operations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
The representation of a node in a graph. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds the given node to the graph.void
Adds a directed edge between the two given nodes.void
clear()
Clears all nodes and edges from this graph.boolean
Gets if the graph contains a node with the given data.@Nullable DirectedGraph.DataNode<D>
Gets the node corresponding to the given data.int
Gets the count of edges in the graph.int
Gets the count of nodes in the graph.getNodes()
Gets all nodes in the graph.boolean
Deletes the given node from the graph, and all edges that originated from or connected to the node.reverse()
Returns a directed graph which represents the reverse of this graph.toString()
-
Constructor Details
-
DirectedGraph
public DirectedGraph()
-
-
Method Details
-
getNodeCount
public int getNodeCount()Gets the count of nodes in the graph. -
getEdgeCount
public int getEdgeCount()Gets the count of edges in the graph. -
contains
Gets if the graph contains a node with the given data. -
get
Gets the node corresponding to the given data. -
addEdge
Adds a directed edge between the two given nodes. If either the start or the end data does not have a corresponding node in the graph then a new node is added. -
getNodes
Gets all nodes in the graph. -
reverse
Returns a directed graph which represents the reverse of this graph. The reverse of a directed graph is a graph with the same nodes but the direction of each edge is reversed. -
add
Adds the given node to the graph. -
remove
Deletes the given node from the graph, and all edges that originated from or connected to the node. -
clear
public void clear()Clears all nodes and edges from this graph. -
toString
-