latest release

graphs

graphs is a simple graph library for Scala

Example

sourceimport com.flowtick.graphs._
import com.flowtick.graphs.defaults._

val graph: Graph[Unit, String] =
  Graph.fromEdges(Set("A" --> "B", "B" --> "C", "D" --> "A"))

println(graph.edges)

Documentation

Please check the guide and the API docs

Features

  • Simple graph creation API
  • Depth-first traversal / search
  • Breadth-first traversal / search
  • Topological sorting
  • Dijkstras algorithm for shortest paths
  • GraphML import / export (experimental)
  • force based layout (planned)
  • cross compiled for Scala 2.12, 2.13, Scala.js

Motivation

graphs was created to explore different type encoding for graphs and implement well-known algorithms

Goals

  • Support Scala.js
  • Support GraphML
  • Usages of the library and the core interfaces should be intuitive
  • The codebase should follow current idioms and integrate with mainstream libraries for Scala

Non-Goals

  • Support all possible graph types / scenarios
  • Provide a purely functional library

Alternatives

Graph for Scala is probably the most established graph library for Scala and supports many kinds of graphs explicitly (custom syntax etc.) with a big variety of algorithms and extensions (json, dot support).

Its still being worked on and recently added support for Scala.js. It might have a steeper learning curve but is more battle-tested and powerful then graphs.

quiver follows Martin Erwigs Functions Graph Library and appears to be more or less abandoned. Its less focused on algorithms but provides a more functional perspective on graphs.

graphs is inspired and influenced by both libraries. Please check them out to see if they fit your use case and preferences better.

License

graphs is published under the terms of the Apache 2.0 License. See the LICENSE file.

The source code for this page can be found here.