scala的图形库 [英] graph library for scala
问题描述
有没有一个好的库(或者Java库的封装) code.google.com/p/scala-graphs/rel =noreferrer>这个
我们为设备项目开发了一个小型图库。你可以看看它这里。它不是纯粹的功能,也不是拉链图,但对我们来说做得很好。您还可以获得可变和不可变的图形。
以下是创建图形的一个简单示例:
隐式val factory = DefaultEdge [String](_,_)
val G =图表(
Entry - >A,
A - >B,
B - >C,
B - >D,
D - >F,
F - >E,
E - >F,
E - >C,
C - > A,
C - >退出)
G.dotExport给Console.out
查找SCC和子组件
G.sccs foreach println
G.sccs map { _.entry} foreach println
G.sccs filter {_.canSearch} map {_.subcomponents} foreach {_ foreach println}
$ (x <-Gtopsort)println(x)
遍历
(x < - G.dft(y))println(x)
目前的缺点是该库仅支持不变类型,并且对于整个g不具有完整性raph库。
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.
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.
这篇关于scala的图形库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!