Directed graph using an adjacency list representation.
Instance methods
add_edge(from : T, to : T)
Adds an edge between two nodes. If the nodes don't exist they will be automatically added.
Sourceadd_node(name : T)
Add a new node to the graph
Sourceempty?
Check if the graph has no nodes
Sourcehas_edge?(from : T, to : T) : Bool
Check if an edge exists between two nodes
Sourcehas_node?(name : T) : Bool
Check if a node exists in the graph
Sourceneighbors(name : T) : Set(T)
Get the neighbors of a node
Sourcenodes
Get all nodes in the graph
Sourcesize
Returns the number of nodes in the graph
Source