/* minspantree.c graph.h を同じディレクトリに download して用いよ コンパイル命令と実行命令: gcc minspantree.c -o minspantree ./minspantree K. Shiota 2005.6.13 */ #define MAXORDER 256 #include "graph.h" main() { Graph g,t; int k; // 乱数の初期化 srand(time(NULL)); // ランダムなグラフの場合 g=EmptyGraph(2); while(!ConnectedQ(g)) g=RandomWeightedGraph(32,1,9); // g=CompleteGraph(9); // g=CompleteBipartiteGraph(5,5); // g=kDimensionalCubicGraph(3); // g=Cycle(5); // g=Cycle(6); // g=GraphSum(CompleteGraph(4),CompleteGraph(5)); printf("\nGraph :\n"); WriteGraph(g); t=MinSpanningTree(g); printf("\nMinimum Spanning Tree :\n"); WriteGraph(t); printf("\nWeight = %d\n",CountEdge(t)); }