本文介绍了scala的图形库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 有没有一个好的库(或者Java库的封装) code.google.com/p/scala-graphs/rel =noreferrer>这个似乎已经死了。 这是在斯卡拉的Dijkstra算法的例子,但我正在寻找library a-la JGraphT 。解决方案我们为设备项目开发了一个小型图库。你可以看看它这里。它不是纯粹的功能,也不是拉链图,但对我们来说做得很好。您还可以获得可变和不可变的图形。 以下是创建图形的一个简单示例: 隐式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 遍历 (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.outFinding SCCs and subcomponentsG.sccs foreach printlnG.sccs map { _.entry } foreach printlnG.sccs filter { _.canSearch } map { _.subcomponents } foreach { _ foreach println }Traversalfor(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的图形库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-03 17:05