module CGL::AdjacencyHash(V, W, L)

Overview

Reusable adjacency list representation for an AnyGraph.

Uses a hash table to associate each vertex V with a set of adjacent vertices. The set is backed by another hash table that can be used to store arbitrary data of type L and a weight of type W with each edge.

Direct including types

Defined in:

cgl/representations/adjacency.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(vertices : Enumerable(V) | Nil = nil, edges : Enumerable(Tuple(V, V)) | Nil = nil, weights : Enumerable(W) | Nil = nil, labels : Enumerable(L | Nil) | Nil = nil, *, default_weight : W | Nil = nil, &block : -> L | Nil) #

[View source]
def self.new(vertices : Enumerable(V) | Nil = nil, edges : Enumerable(Tuple(V, V)) | Nil = nil, weights : Enumerable(W) | Nil = nil, labels : Enumerable(L | Nil) | Nil = nil, *, default_weight : W | Nil = nil, default_label : L | Nil = nil) #

[View source]
def self.new(edges : Enumerable(AnyEdge(V)), *, default_weight : W | Nil = nil, &block : -> L | Nil) #

[View source]
def self.new(edges : Enumerable(AnyEdge(V)), *, default_weight : W | Nil = nil, default_label : L | Nil = nil) #

[View source]

Instance Method Detail

def add_edge(edge : AnyEdge(V)) #

[View source]
def add_vertex(v : V) #

[View source]
def clear #

[View source]
def each_adjacent(u : V, & : V -> ) #

[View source]
def each_adjacent(u : V) : Iterator(V) #

[View source]
def each_vertex(& : V -> ) #

[View source]
def each_vertex : Iterator(V) #

[View source]
def has_edge?(u : V, v : V, weight : W, label : L | Nil) : Bool #

[View source]
def has_edge?(u : V, v : V, weight, label) : Bool #

[View source]
def has_edge?(u : V, v : V) : Bool #

[View source]
def has_vertex?(v : V) : Bool #

[View source]
def label_block : -> L | Nil #

The block triggered for default edge labels.


[View source]
def label_of(u : V, v : V) : L | Nil #

[View source]
def label_of?(u : V, v : V) : L | Nil #

[View source]
def labeled? : Bool #

Whether edges are labeled.


[View source]
def order : Int32 #

[View source]
def size : Int32 #

The number of edges in self.


[View source]
def vertices #

[View source]
def weight_of(u : V, v : V) : W #

[View source]
def weight_of?(u : V, v : V) : W | Nil #

[View source]
def weighted? : Bool #

Whether edges are weighted.


[View source]