Scala 图形库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2443885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 02:00:18  来源:igfitidea点击:

graph library for scala

scalagraph

提问by Elazar Leibovich

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

scala 中是否有用于图形和/或图形算法的好的库(或 Java 库的包装器)?

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

这个好像已经死了。是 Scala 中 Dijkstra 算法的一个示例,但我正在寻找一个库 a-la JGraphT

采纳答案by Joa Ebert

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.

我们为 apparat 项目开发了一个小型图形库。您可以在此处查看。它不是纯粹的功能,也不是拉链图,但对我们来说做得很好。您还可以获得可变和不可变图形。

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

查找 SCC 和子组件

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.

当前的缺点是该库仅支持不变类型,而不支持整个图形库的功能完整。

回答by opyate

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

目前有一个意见征集来创建一个内置到 Scala 库中的 scala.collection.Graph。

Also, how about developing a Scala wrapper for JGraphT?

另外,如何为 JGraphT 开发一个 Scala 包装器?

UPDATE

更新

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

Scala Graph现在已经超出了讨论阶段,而且还在进行中。

回答by sw.

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

为什么不是荣格?还有用于图形的Piccolo2D?(均基于 JVM)。

回答by Michael Pollmeier

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.

Gremlin-Scala 是 Gremlin 的瘦 Scala 包装器,Gremlin 是一种图形 DSL,用于遍历许多图形数据库,包括 Neo4j、OrientDB、DEX、InfiniteGraph、Titan、Rexster 图形服务器和符合 Sesame 2.0 的 RDF 存储。

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

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

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

注意:我有偏见,因为我是作者;)