class Werk::Utils::Graph

Overview

Minimal implementation for a Directed Acyclic Graph.

Defined in:

werk/utils/graph.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Creates a new empty graph. The implementation uses an adjacency list representation for the graph.


[View source]

Instance Method Detail

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

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


[View source]
def add_vertex(name : String) #

Add a new vertex to the graph


[View source]
def get_vertices #

Get all vertices for the graph


[View source]
def topological_sort #

Return the vertices of the graph sorted topologically. The algorithm uses clustered output to allow for parallel processing.


[View source]