0% menganggap dokumen ini bermanfaat (0 suara)
182 tayangan11 halaman

Algoritma Minimum Spanning Tree

Dokumen tersebut membahas tentang minimum spanning tree. Ia menjelaskan definisi minimum spanning tree, algoritma-algoritma untuk mencari minimum spanning tree seperti algoritma Kruskal, Prim, dan Solin, serta contoh penerapan ketiga algoritma tersebut pada suatu graf.

Diunggah oleh

Hadi Muammar
Hak Cipta
© All Rights Reserved
Kami menangani hak cipta konten dengan serius. Jika Anda merasa konten ini milik Anda, ajukan klaim di sini.
Format Tersedia
Unduh sebagai DOCX, PDF, TXT atau baca online di Scribd
0% menganggap dokumen ini bermanfaat (0 suara)
182 tayangan11 halaman

Algoritma Minimum Spanning Tree

Dokumen tersebut membahas tentang minimum spanning tree. Ia menjelaskan definisi minimum spanning tree, algoritma-algoritma untuk mencari minimum spanning tree seperti algoritma Kruskal, Prim, dan Solin, serta contoh penerapan ketiga algoritma tersebut pada suatu graf.

Diunggah oleh

Hadi Muammar
Hak Cipta
© All Rights Reserved
Kami menangani hak cipta konten dengan serius. Jika Anda merasa konten ini milik Anda, ajukan klaim di sini.
Format Tersedia
Unduh sebagai DOCX, PDF, TXT atau baca online di Scribd

Minimum Spanning Tree

Disusun oleh : Bheli Isya K. K.


4515210016

MINIMUM SPANNING TREE


Pencarian biaya yang minimum dari suatu graph sehingga
membentuk pohon .
Syarat Graph yang dapat dicari minimum spanning treenya :
a. Graph harus terhubung
b. Ruasnya punya bobot
c. Graph tidak berarah
Algoritma yang dipakai untuk menentukan minimum
spanning tree :
a. Algoritma Kruskal
b. Algoritma Solin
c. Algoritma Prim

a. Algoritma Kruskal
Himpunan sisi dari G diurutkan membesar sesuai bobot
sisi tersebut.
Buat T dengan memasukan 1 sisi terpendek dari G
tersebut.
Ulang (banyak sisi T = (banyak simpul G)-1)
a. Ambil sisi selanjutnya dari G.
b. Jika sisi itu tidak membuat sirkuit di T
i. Masukan sisi itu ke T
ii. Masukan simpul-simpul sisi itu ke T

Pseudo Code Algoritma Kruskal

b. Algoritma Solin
Algoritma Solin untuk MST merupakan kebalikan dari
algoritma Kruskal, yaitu membuat tree didahului dengan
melakukan pengurutan garis dari garis yang mempunyai
bobot terbesar. Algoritma Solin tidak akan dibahas lebih
lanjut dalam makalah ini.
c. Algoritma Prim
Ambil sisi graph G yang berbobot minimum, masukan
kedalam T.
Pilih sisi (u,v) yang memiliki bobot minimum dan bersisian
dengan simpul di T. Tetapi (u,v) tidak membentuk sirkuit di
T. Tambahkan (u,v) kedalam T.
Ulangi langkah ke-2 sebanyak (n-2) kali.

Pseudo Code Algoritma Prim

1. Algoritma Solin
Suatu Graph G, seperti gambar di bawah [Link] adalah graf
berbobot awal. Graf ini
bukan pohon karena ada sirkuit. Nama yang lebih tepat
untuk diagram ini adalah
Graf atau [Link]-angka dekat garis
penghubung/ruas adalah bobotnya.
Nilai bobot dari Graf tesebut adalah : 86

Kita akan mencari MST dengan menggunakan Algoritma Solin dan


Kruskal untuk Graf G
diatas.

Penyeselaian :
a.
Urutkan Ruas Graf (G) menurut bobotnya dari bobot
yang terbesar sampai bobot
yang terkecil.
Bobot RUAS

15 D,E
9 B,D E,F
8 B,C B,E F,G
7 A,D C,E
6 A,B E,G
5 D,F
b. Lakukan penghapusan masing-masing ruas yang tidak
menyebabkan graf menjadi tidak terhubung atau
membentuk sirkuit.
Kita mulai melakukan tahapan penghapusan dengan ruas
dengan nilai bobot terbesar sampai bobot terkecil :

Tahap Penghapusan Selesai, Gambar 6 adalah Minimun Spanning


Tree dari Graf G
dengan Nilai Bobot : 56

2. Algoritma Kruskal
Dengan Graph yang sama, kita akan mencari Minimun
Spanning Tree dengan algoritma Kruskal.
a. Mula-mula kita buat Graf G hanya terdiri dari Simpul saja.

b. Urutkan Ruas dari bobot kecil ke besar (DF, AB, EG, AD,
CE, BC, BE, FG, BD,
EF,DE), kemudian berdasarkan urutan tersebut, kita
menambahkan ruas dengan
mencegah terbentuknya sirkuit.

Contoh Program Dan Algoritma

Common questions

Didukung oleh AI

Edge weights are critical in constructing an MST as they determine the selection and order of edges when forming the tree. Algorithms prioritize edges with lower weights to ensure the sum of edge weights in the final tree is minimized. This selection process shapes the tree's structure by favoring lighter connections and directly influences both its layout and total cost .

Cycle detection is crucial in Kruskal's algorithm to ensure that adding an edge does not form a cycle, thus violating the properties of a tree. It is usually implemented using a disjoint-set data structure or union-find, which efficiently supports union and find operations to track and merge connected components of the graph .

Prim's algorithm begins by selecting an arbitrary vertex as the starting point and adding edges to a growing MST that connect the tree to other vertices. It repeatedly selects the smallest weight edge that extends the tree without forming a cycle, ensuring that at each step, the edge added is the minimum possible to maintain connectedness without cycles, thereby ensuring the total weight of the MST is minimized .

Solin's algorithm constructs a spanning tree by starting with the complete graph and successively removing the heaviest edges, opposite to Kruskal's method of adding the lightest edges. It continues this removal process while ensuring that the graph remains connected and does not become disjoint, resulting in a Minimum Spanning Tree once no more edges can be removed without disconnecting the graph .

The pseudocode for Kruskal's algorithm can optimize performance by using a union-find data structure with path compression to manage disjoint sets of vertices. This approach ensures that union and find operations remain nearly constant time on average, significantly speeding up the process of cycle detection. Additionally, leveraging efficient sort algorithms for edge ordering enhances runtime in practical implementations .

Kruskal's algorithm starts by sorting all edges by weight and adding them to the MST in non-decreasing order without forming cycles, thus requiring the use of a disjoint set data structure to manage component connectivity. Prim's algorithm, on the other hand, begins with a single vertex and grows the MST by adding the shortest possible edge from the graph that connects a vertex in the MST with a vertex outside it, often employing a priority queue data structure for efficient edge selection .

The choice between Kruskal's and Prim's algorithms depends largely on the graph's density. Kruskal's algorithm is more suitable for sparse graphs due to its edge-centric approach, efficiently managing disconnected components and leveraging sorting. Meanwhile, Prim's algorithm is advantageous for dense graphs because it efficiently expands a tree with lower overhead by using priority queues, minimizing necessary edge checks. Thus, the decision hinges on the graph's edge-to-vertex ratio and specific computational constraints .

A graph must be connected to apply MST algorithms like Kruskal's and Prim's because these algorithms require that there exists a path between any two vertices in the graph. Disconnected graphs would result in multiple disjoint trees, preventing the formation of a single spanning tree encompassing all vertices, which is the objective of MST algorithms .

An MST is a subset of edges in a connected, weighted, and undirected graph that connects all the vertices together without any cycles and with the minimum possible total edge weight. To determine the MST, the graph must be connected, have weighted edges, and be undirected .

The efficiency of Kruskal's algorithm can be significantly impacted by the time complexity of sorting edges, which is O(E log E) where E is the number of edges. For large graphs, this sorting step can become a bottleneck, especially if the graph is dense with many edges. However, Kruskal's ability to handle disconnected components makes it suitable for sparse graphs and those with smaller edge counts relative to the number of vertices .

Anda mungkin juga menyukai