Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

graph library for scala [closed]

Tags:

graph

scala

Is there a good library (or wrapper to Java library) for graphs, and/or graph algorithms in scala?

This one seems to be quite dead. This is an example for the Dijkstra algorithm in scala, but I'm looking for a library a-la JGraphT.

like image 736
Elazar Leibovich Avatar asked Mar 14 '10 21:03

Elazar Leibovich


4 Answers

There is a current call-for-comments to create a scala.collection.Graph built-in into the Scala library.

Also, how about developing a Scala wrapper for JGraphT?

UPDATE

Graph for Scala is now beyond the discussion stage, and a work-in-progress.

like image 112
opyate Avatar answered Nov 13 '22 10:11

opyate


We have developed a small graph library for the apparat project. You can take a look at it here. It is not purely functional and not a zipper graph but does a good job for us. You get also mutable and immutable graphs.

Here is a simple example for graph creation:

implicit val factory = DefaultEdge[String](_, _)
val G = Graph(
  "Entry" -> "A",
  "A" -> "B",
  "B" -> "C",
  "B" -> "D",
  "D" -> "F",
  "F" -> "E",
  "E" -> "F",
  "E" -> "C",
  "C" -> "A",
  "C" -> "Exit")
G.dotExport to Console.out

Finding SCCs and subcomponents

G.sccs foreach println
G.sccs map { _.entry } foreach println
G.sccs filter { _.canSearch } map { _.subcomponents } foreach { _ foreach println }

Traversal

for(x <- G.topsort) println(x)
for(x <- G.dft(y)) println(x)

The current drawback is that the library is supporting only invariant types and not feature complete for a whole graph library.

like image 9
Joa Ebert Avatar answered Nov 13 '22 08:11

Joa Ebert


Why not Jung ? and also Piccolo2D for graphics? (both JVM based).

like image 4
sw. Avatar answered Nov 13 '22 08:11

sw.


Gremlin-Scala is a thin thin Scala wrapper for Gremlin, a graph DSL for traversing a number of graph databases including Neo4j, OrientDB, DEX, InfiniteGraph, Titan, Rexster graph server, and Sesame 2.0 compliant RDF stores.

https://github.com/mpollmeier/gremlin-scala

Note: I am biased as I'm the author ;)

like image 2
Michael Pollmeier Avatar answered Nov 13 '22 08:11

Michael Pollmeier