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, edges : Enumerable(Tuple(V, V))? = nil, weights : Enumerable(W)? = nil, labels : Enumerable(L?)? = nil, *, default_weight : W? = nil, &block : -> L?) #

def self.new(vertices : Enumerable(V)? = nil, edges : Enumerable(Tuple(V, V))? = nil, weights : Enumerable(W)? = nil, labels : Enumerable(L?)? = nil, *, default_weight : W? = nil, default_label : L? = nil) #

def self.new(edges : Enumerable(AnyEdge(V)), *, default_weight : W? = nil, &block : -> L?) #

def self.new(edges : Enumerable(AnyEdge(V)), *, default_weight : W? = nil, default_label : L? = nil) #

Instance Method Detail

def add_edge(edge : AnyEdge(V)) #

def add_vertex(v : V) #

def clear #

def each_adjacent(u : V) : Iterator(V) #

def each_adjacent(u : V, & : V -> ) #

def each_vertex : Iterator(V) #

def each_vertex(& : V -> ) #

def has_edge?(u : V, v : V, weight : W, label : L?) : Bool #

def has_edge?(u : V, v : V, weight, label) : Bool #

def has_edge?(u : V, v : V) : Bool #

def has_vertex?(v : V) : Bool #

def label_block : -> L? #

The block triggered for default edge labels.


def label_of(u : V, v : V) : L? #

def label_of?(u : V, v : V) : L? #

def labeled? : Bool #

Whether edges are labeled.


def order : Int32 #

def size : Int32 #

The number of edges in self.


def vertices #

def weight_of(u : V, v : V) : W #

def weight_of?(u : V, v : V) : W? #

def weighted? : Bool #

Whether edges are weighted.