1 / 20

Pertemuan 22 Graph Operation

Pertemuan 22 Graph Operation. Matakuliah : T0026/Struktur Data Tahun : 2005 Versi : 1/1. Learning Outcomes. Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : Mahasiswa dapat menghasilkan program modular untuk mengimplementasikan graph operation dan spanning tree.

kaiser
Download Presentation

Pertemuan 22 Graph Operation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pertemuan 22Graph Operation Matakuliah : T0026/Struktur Data Tahun : 2005 Versi : 1/1

  2. Learning Outcomes Pada akhir pertemuan ini, diharapkan mahasiswa akan mampu : • Mahasiswa dapat menghasilkan program modular untuk mengimplementasikan graph operation dan spanning tree

  3. Outline Materi • Pengertian graph operation • Graph traversal • Depth First Search • Breadth First Search • Contoh operasi DFS dan DFS • Spanning Tree • Contoh konstruksi Spanning Tree

  4. Graph Traversal • Depth First Search (DFS) Algoritma akan memanfaatkan stack • Bread First Search (BFS) Algoritma akan memanfaatkan queue Pembahasan DFS dan BFS akan menggunakan representasi Adjacency List Pada saat mengunjungi sebuah node, nama node akan dicetak

  5. Graph – DEPTH FIRST SEARCH Algoritma DFS : For (all v in G) visited[v] = FALSE; void dfs (int v) { node_pointer w; visited[v] = TRUE; printf (“%d”, v); for (w = graph[v]; w; w=w->link) if (!visited[w->vertex]) dfs(w->vertex); }

  6. Graph – BREADTH FIRST SEARCH (BFS) Algoritma BFS: void BFS(G){ for (all v in G) { if (visited[v] = FALSE){ EnQueue(v,Queue); do { DeQueue(v, Queue); visited[v] = TRUE; Visit(v); for (all w adjacent to v) if (visited(w)= FALSE) EnQueue(w,Queue); } while (!Empty(Queue)); } } }

  7. Vo V1 V2 0 1 2 1 0 3 4 V3 V4 V5 V6 2 0 5 6 3 1 7 V7 4 1 7 5 2 7 6 2 7 7 3 4 5 3 Graph – Contoh(1) Adjacency List : perhatikan urutan node pd edge list sesuai dengan urutan head node list

  8. Graph – Contoh(1) - DEPTH FIRST SEARCH (DFS)

  9. Vo V1 V2 V3 V4 V5 V6 V7 Graph – Contoh(1) – Hasil DFS dan BFS Hasil DFS Hasil BFS Vo V1 V2 V3 V4 V5 V6 V7

  10. Graph – BREADTH FIRST SEARCH (BFS)

  11. Graph – BREADTH FIRST SEARCH (BFS)

  12. A B F C E D A B C D B A C E F C A B E D A E E B C D F F B E Graph – Contoh 2

  13. Graph – Contoh 2 - DFS

  14. Graph – Contoh(2) - BFS

  15. A B F A B F C E C E D D Graph – Contoh(2) – Hasil DFS dan BFS Hasil DFS Hasil BFS

  16. A B E C F G A B C D H D B A C E F C A B F D A F G H E B F D E G F B C G D F H D Graph – Contoh 3

  17. Graph – Contoh(3) - DEPTH FIRST SEARCH (DFS)

  18. Graph – Contoh(3) - BREADTH FIRST SEARCH (BFS)

  19. A B E A B E C F G C F G H H D D Graph – Contoh(3) - DEPTH FIRST SEARCH (DFS) Hasil DFS Hasil BFS

More Related