全部最小生成树的实现最小、全部

2023-09-10 23:56:40 作者:挽梦亦清歌

我一直在寻找一个实现(我使用 networkx 库),将发现所有的最小生成树( MST)无向加权图的。

I've been looking for an implementation (I'm using networkx library.) that will find all the minimum spanning trees (MST) of an undirected weighted graph.

我只能找到的实现Kruskal算法和Prim算法两者都将只返回一个MST。

I can only find implementations for Kruskal's Algorithm and Prim's Algorithm both of which will only return a single MST.

我已经看到了解决这一问题的文件(如重新presenting所有最小生成树与应用程序进行计数和代),但我的头往往通过冥思苦想如何将其转化为code好歹爆炸。

I've seen papers that address this problem (such as Representing all minimum spanning trees with applications to counting and generation) but my head tends to explode someway through trying to think how to translate it to code.

其实我一直没能找到任何语言的实现!

In fact i've not been able to find an implementation in any language!

推荐答案

Rubys给出了一个很好的一般的答案。但是,编写有效的code生成图的所有生成树是一个挑战,一个野兽。

Rubys gives a good general answer. But writing efficient code to generate all spanning trees of a graph is a beast of a challenge.

半路此页面,在2003年左右十二月,你会发现一个CWEB实现Knuth的算法查找给定图的所有生成树。

Half way down this page, at around Dec 2003, you'll find an CWEB implementation of Knuth's algorithm that finds all spanning trees of a given graph.