class Craph::Graph(T)

Overview

Directed graph using an adjacency list representation.

Direct Known Subclasses

Defined in:

craph/graph.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def add_edge(from : T, to : T) #

Adds an edge between two nodes. If the nodes don't exist they will be automatically added.


[View source]
def add_node(name : T) #

Add a new node to the graph


[View source]
def empty? #

Check if the graph has no nodes


[View source]
def has_edge?(from : T, to : T) : Bool #

Check if an edge exists between two nodes


[View source]
def has_node?(name : T) : Bool #

Check if a node exists in the graph


[View source]
def neighbors(name : T) : Set(T) #

Get the neighbors of a node


[View source]
def nodes #

Get all nodes in the graph


[View source]
def size #

Returns the number of nodes in the graph


[View source]