All Projects → snowleopard → Alga

snowleopard / Alga

Licence: mit
Algebraic graphs

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Alga

Typescript
Algebraic graphs implementation in TypeScript
Stars: ✭ 107 (-82.71%)
Mutual labels:  graph, algebra
Alga Paper
A minimalistic, elegant and powerful approach to working with graphs in a functional programming language
Stars: ✭ 163 (-73.67%)
Mutual labels:  graph, algebra
agda
The theory of algebraic graphs formalised in Agda
Stars: ✭ 67 (-89.18%)
Mutual labels:  algebra, graph
Chat
基于自然语言理解与机器学习的聊天机器人,支持多用户并发及自定义多轮对话
Stars: ✭ 516 (-16.64%)
Mutual labels:  graph
Madge
Create graphs from your CommonJS, AMD or ES6 module dependencies
Stars: ✭ 5,635 (+810.34%)
Mutual labels:  graph
Kotlin 99
Ninety-Nine Problems in Kotlin
Stars: ✭ 568 (-8.24%)
Mutual labels:  graph
Quickqanava
C++14 network/graph visualization library / Qt node editor.
Stars: ✭ 611 (-1.29%)
Mutual labels:  graph
Ncalc
Power calculator for Android. Solve some problem algebra and calculus.
Stars: ✭ 512 (-17.29%)
Mutual labels:  algebra
Smile
Statistical Machine Intelligence & Learning Engine
Stars: ✭ 5,412 (+774.31%)
Mutual labels:  graph
Esp Dash
A blazing fast library to create a functional dashboard for ESP8266 and ESP32
Stars: ✭ 548 (-11.47%)
Mutual labels:  graph
React D3 Tree
🌳 React component to create interactive D3 tree graphs
Stars: ✭ 543 (-12.28%)
Mutual labels:  graph
Ttyplot
a realtime plotting utility for terminal/console with data input from stdin
Stars: ✭ 532 (-14.05%)
Mutual labels:  graph
Ngd
View the dependencies tree of you Angular application
Stars: ✭ 570 (-7.92%)
Mutual labels:  graph
Scala Graph
Graph for Scala is intended to provide basic graph functionality seamlessly fitting into the Scala Collection Library. Like the well known members of scala.collection, Graph for Scala is an in-memory graph library aiming at editing and traversing graphs, finding cycles etc. in a user-friendly way.
Stars: ✭ 521 (-15.83%)
Mutual labels:  graph
Eliasdb
EliasDB a graph-based database.
Stars: ✭ 611 (-1.29%)
Mutual labels:  graph
Gonum
Gonum is a set of numeric libraries for the Go programming language. It contains libraries for matrices, statistics, optimization, and more
Stars: ✭ 5,384 (+769.79%)
Mutual labels:  graph
Swiftgraph
A Graph Data Structure in Pure Swift
Stars: ✭ 588 (-5.01%)
Mutual labels:  graph
Specs
Content-addressed, authenticated, immutable data structures
Stars: ✭ 539 (-12.92%)
Mutual labels:  graph
Opencypher
Specification of the Cypher property graph query language
Stars: ✭ 534 (-13.73%)
Mutual labels:  graph
Sgc
official implementation for the paper "Simplifying Graph Convolutional Networks"
Stars: ✭ 566 (-8.56%)
Mutual labels:  graph

Algebraic graphs

Hackage version Build status

Alga is a library for algebraic construction and manipulation of graphs in Haskell. See this Haskell Symposium paper and the corresponding talk for the motivation behind the library, the underlying theory and implementation details. There is also a Haskell eXchange talk, and a tutorial by Alexandre Moine.

Main idea

Consider the following data type, which is defined in the top-level module Algebra.Graph of the library:

data Graph a = Empty | Vertex a | Overlay (Graph a) (Graph a) | Connect (Graph a) (Graph a)

We can give the following semantics to the constructors in terms of the pair (V, E) of graph vertices and edges:

  • Empty constructs the empty graph (∅, ∅).
  • Vertex x constructs a graph containing a single vertex, i.e. ({x}, ∅).
  • Overlay x y overlays graphs (Vx, Ex) and (Vy, Ey) constructing (Vx ∪ Vy, Ex ∪ Ey).
  • Connect x y connects graphs (Vx, Ex) and (Vy, Ey) constructing (Vx ∪ Vy, Ex ∪ Ey ∪ Vx × Vy).

Alternatively, we can give an algebraic semantics to the above graph construction primitives by defining the following type class and specifying a set of laws for its instances (see module Algebra.Graph.Class):

class Graph g where
    type Vertex g
    empty   :: g
    vertex  :: Vertex g -> g
    overlay :: g -> g -> g
    connect :: g -> g -> g

The laws of the type class are remarkably similar to those of a semiring, so we use + and * as convenient shortcuts for overlay and connect, respectively:

  • (+, empty) is an idempotent commutative monoid.
  • (*, empty) is a monoid.
  • * distributes over +, that is: x * (y + z) == x * y + x * z and (x + y) * z == x * z + y * z.
  • * can be decomposed: x * y * z == x * y + x * z + y * z.

This algebraic structure corresponds to unlabelled directed graphs: every expression represents a graph, and every graph can be represented by an expression. Other types of graphs (e.g. undirected) can be obtained by modifying the above set of laws. Algebraic graphs provide a convenient, safe and powerful interface for working with graphs in Haskell, and allow the application of equational reasoning for proving the correctness of graph algorithms.

To represent non-empty graphs, we can drop the Empty constructor -- see module Algebra.Graph.NonEmpty.

To represent edge-labelled graphs, we can switch to the following data type, as explained in my Haskell eXchange 2018 talk:

data Graph e a = Empty
               | Vertex a
               | Connect e (Graph e a) (Graph e a)

Here e is the type of edge labels. If e is a monoid (<+>, zero) then graph overlay can be recovered as Connect zero, and <+> corresponds to parallel composition of edge labels.

How fast is the library?

Alga can handle graphs comprising millions of vertices and billions of edges in a matter of seconds, which is fast enough for many applications. We believe there is a lot of potential for improving the performance of the library, and this is one of our top priorities. If you come across a performance issue when using the library, please let us know.

Some preliminary benchmarks can be found here.

Blog posts

The development of the library has been documented in the series of blog posts:

Algebraic graphs in other languages

Algebraic graphs were implemented in a few other languages, including Agda, F#, Scala and TypeScript.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].