class

Craph::Graph(T)

Inherits Reference / Object

Directed graph using an adjacency list representation.

Constructors

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.

Source
add_node(name : T)

Add a new node to the graph

Source
empty?

Check if the graph has no nodes

Source
has_edge?(from : T, to : T) : Bool

Check if an edge exists between two nodes

Source
has_node?(name : T) : Bool

Check if a node exists in the graph

Source
neighbors(name : T) : Set(T)

Get the neighbors of a node

Source
nodes

Get all nodes in the graph

Source
size

Returns the number of nodes in the graph

Source