/Grun.Math

A sample of Algorithms in C# 7

Primary LanguageC#MIT LicenseMIT

Build status Build Status

Grun.Math

A set of Graph computations where a graph is defined as a source vertex and a function which computes the adjacency list for a vertex. This definition of graph is useful in situations where computing the entire graph is computationally or memory intensive or in distributed computing scenarios. Since edges are not precomputed, an algorithm may be shortcircuited in a more efficient manner than if the entire graph were loaded into memory.

Define graph G:=(V,E) where:

set V of vertices in G Node[] V = { node0, node1, node2 };

set E of edges in G var E = new(Node v1, Node v2)[] {(node0, node1), (node0, node2)};

adjacency computation - define graph as function

Func<Node, IEnumerable<Node>> graph = (v) => lookup[v];
    
Assert.Equal(false, graph.HasCycle(node0));```