プリンキピア

第12章グラフ理論

Kruskal’s Algorithmクラスカルのアルゴリズム

In many applications of spanning trees, the graphs are weighted and we want to find the spanning tree of least possible weight. For example, the graph might represent a computer network, and the weights might represent the cost involved in connecting two devices. So, finding a spanning tree with the lowest possible total weight, or minimum spanning tree, means saving money! The method that we will use to find a minimum spanning tree of a weighted graph is called Kruskal’s algorithm. The steps for Kruskal’s algorithm are:
英語のヒント
全域木の多くの応用では、グラフは重みつきで、可能な最小の重みの全域木を見つけたい。たとえば、グラフがコンピュータネットワークを表し、重みが2台の機器をつなぐ費用を表すかもしれない。だから、重みの合計が可能な最小である全域木、つまり最小全域木を見つけることはお金の節約を意味する!重みつきグラフの最小全域木を見つけるのに使う方法を、クラスカルのアルゴリズムという。クラスカルのアルゴリズムの手順は次のとおりである:
Step 1: Choose any edge with the minimum weight of all edges.
英語のヒント
手順1:すべての辺のなかで重みが最小の辺を1本選ぶ。
Step 2: Choose another edge of minimum weight from the remaining edges. The second edge does not have to be connected to the first edge.
英語のヒント
手順2:残りの辺から重みが最小の別の辺を選ぶ。2本目の辺は1本目の辺につながっていなくてよい。
Step 3: Choose another edge of minimum weight from the remaining edges, but do not select any edge that creates a cycle in the subgraph you are creating.
英語のヒント
手順3:残りの辺から重みが最小の別の辺を選ぶが、作っている部分グラフに閉路を作る辺は選ばない。
Step 4: Repeat step 3 until all the vertices of the original graph are included and you have a spanning tree.
英語のヒント
手順4:もとのグラフのすべての頂点が含まれて全域木ができるまで手順3を繰り返す。
Example 12.52例題 12.52

Using Kruskal’s Algorithmクラスカルのアルゴリズムを使う

A computer network will be set up with six devices. The vertices in the graph in Figure 12.229 represent the devices, and the edges represent the cost of a connection. Find the network configuration that will cost the least. What is the total cost?
英語のヒント
6台の機器でコンピュータネットワークを組む。図12.229のグラフの頂点は機器を表し、辺は接続の費用を表す。費用がいちばん少ないネットワークの構成を見つけよ。費用の合計はいくらか。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars.
Figure 12.229図12.229
Graph of Network Connection Costs
英語のヒント
ネットワークの接続費用のグラフ
Solution解答
A minimum spanning tree will correspond to the network configuration of least cost. We will use Kruskal’s algorithm to find one. Since the graph has six vertices, the spanning tree will have six vertices and five edges.
英語のヒント
最小全域木は、費用がいちばん少ないネットワークの構成に対応する。クラスカルのアルゴリズムを使ってそれを見つける。グラフの頂点は6個なので、全域木は頂点が6個、辺が5本である。
Step 1: Choose an edge of least weight. We have sorted the weights into numerical order. The least is $100. The only edge of this weight is edge AF as shown in Figure 12.230.
英語のヒント
手順1:重みがいちばん小さい辺を選ぶ。重みを数の順に並べた。いちばん小さいのは$100である。この重みの辺は、図12.230に示すように辺AFだけである。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edge, A F is in dashed lines. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100 is struck through.
Figure 12.230図12.230
Step 1 Select Edge AF
英語のヒント
手順1 辺AFを選ぶ
Step 2: Choose the edge of least weight of the remaining edges, which is BD with $120. Notice that the two selected edges do not need to be adjacent to each other as shown in Figure 12.231.
英語のヒント
手順2:残りの辺から重みがいちばん小さい辺を選ぶ。$120のBDである。図12.231に示すように、選んだ2本の辺は互いに隣接していなくてよいことに注意しよう。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edges, A F, and B D are in dashed lines. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100 and 120 are struck through.
Figure 12.231図12.231
Step 2 Select Edge BD
英語のヒント
手順2 辺BDを選ぶ
Step 3: Select the lowest weight edge of the remaining edges, as long as it does not result in a cycle. We select DF with $150 since it does not form a cycle as shown in Figure 12.232.
英語のヒント
手順3:閉路にならないかぎり、残りの辺から重みがいちばん小さい辺を選ぶ。図12.232に示すように閉路を作らないので、$150のDFを選ぶ。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edges, A F, B D, and D F are in dashed lines. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100, 120, and 150 are struck through.
Figure 12.232図12.232
Step 3 Select Edge DF
英語のヒント
手順3 辺DFを選ぶ
Repeat Step 3: Select the lowest weight edge of the remaining edges, which is BE with $160 and it does not form a cycle as shown in Figure 12.233. This gives us four edges so we only need to repeat step 3 once more to get the fifth edge.
英語のヒント
手順3を繰り返す:残りの辺から重みがいちばん小さい辺を選ぶ。$160のBEで、図12.233に示すように閉路を作らない。これで辺が4本になったので、手順3をもう1回繰り返すだけで5本目の辺が得られる。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edges, A F, B D, B E, and D F are in dashed lines. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100, 120, 150, and 160 are struck through.
Figure 12.233図12.233
Repeat Step 3 Select Edge DF
英語のヒント
手順3を繰り返す 辺DFを選ぶ
Repeat Step 3: The lowest weight of the remaining edges is $170. Both BF and CE have a weight of $170, but BF would create cycle (b, d, f) and there cannot be a cycle in a spanning tree as shown in Figure 12.234.
英語のヒント
手順3を繰り返す:残りの辺のいちばん小さい重みは$170である。BFとCEはどちらも重みが$170だが、BFは閉路(b, d, f)を作り、図12.234に示すように全域木に閉路があってはならない。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edges, A F, B D, B E, and DF are in dashed lines. Edge, B F is in red. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100, 120, 150, and 160 are struck through. 170 is crossed out.
Figure 12.234図12.234
Repeat Step 3 Do Not Select Edge BF
英語のヒント
手順3を繰り返す 辺BFを選ばない
So, we will select CE, which will complete the spanning tree as shown in Figure 12.235.
英語のヒント
だから、CEを選ぶ。これで図12.235に示すように全域木が完成する。
A graph represents the airfares between six different cities. The graph has 6 vertices. The vertices are A, B, C, D, E, and F. Edges from A leading to B, C, D, E, and F are labeled 250 dollars, 210 dollars, 300 dollars, 200 dollars, and 100 dollars. Edges from B leading to C, D, E, and F are labeled 220 dollars, 120 dollars, 160 dollars, and 170 dollars. Edges from C to D, E, and F are labeled 310 dollars, 180 dollars, and 330 dollars. Edges from D to E and F 270 dollars and 150 dollars. An edge from E to F is labeled 350 dollars. Edges, A F, B D, B E, C E, and D F are in dashed lines. Cost in dollars are as follows: 100, 120, 150, 160, 170, 170, 200, 210, 220, 250, 270, 300, 310, 330, and 350. 100, 120, 150, 160, and 170 are struck through. 170 is crossed out.
Figure 12.235図12.235
Repeat Step 3 Select Edge CE
英語のヒント
手順3を繰り返す 辺CEを選ぶ
The minimum spanning tree is shown in Figure 12.236. This is the configuration of the network of least cost. The spanning tree has a total weight of $100+$120+$150+$160+$170=$700, which is the total cost of this network configuration.
英語のヒント
最小全域木を図12.236に示す。これが費用がいちばん少ないネットワークの構成である。全域木の重みの合計は$100+$120+$150+$160+$170=$700で、これがこのネットワークの構成の費用の合計である。
A graph has six vertices labeled A to F. The edges are as follows. A F, curved edge, 100 dollars. B E, 160 dollars. B D, 120 dollars. C E, 170 dollars. D F, 150 dollars.
Figure 12.236図12.236
Final Minimum Spanning Tree
英語のヒント
最終的な最小全域木