1 / 61

GRAPH

GRAPH. Oleh : Nur Hayatin, S.ST. Teknik Informatika - Universitas Muhammadiyah Malang (UMM) Tahun Akademik 2010-2011. Sub Topik. Overview : Graph Jenis Graph Implementasi Graph Graph Property Representasi Graph. Graph. Graph. G = (V,E) Dimana :

janna
Télécharger la présentation

GRAPH

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. GRAPH Oleh : Nur Hayatin, S.ST Teknik Informatika - Universitas Muhammadiyah Malang (UMM) Tahun Akademik 2010-2011

  2. Sub Topik • Overview : Graph • Jenis Graph • Implementasi Graph • Graph Property • Representasi Graph

  3. Graph

  4. Graph • G = (V,E) • Dimana : Vadalah Vertex, menyatakan entitas data. Eadalah Edge, menyatakan garis penghubung antar node. • Vertex (Vertices) disebut juga sebagai node atau point. • Edge disebut juga sebagai arcs atau lines. • Setiap edge menghubungkan dua vertices.

  5. Contoh Graph • Contoh persoalan di dunia nyata yang dapat direpresentasikan dengan graph adalah : Jaringan pertemanan pada Facebook.

  6. Nina Firda Riza Toni Joko Ale Jaringan pertemanan pada Facebook Graph dengan 6 node/vertex dan 7 lines/edge yang merepresentasikan jaringan pertemanan pada Facebook

  7. Penjabaran • Node(vertex): para pemakai Facebook • Lines(edge): Garis penghubung antara pemakai satu dengan yang lain. • Sehingga dari contoh graph diatas dapat dijabarkan sebagai berikut : V = {Nina, Toni, Ale, Riza, Joko, Firda} E = {{Nina,Toni},{Toni,Riza},{Nina, Riza}, {Toni,Ale}, {Ale,Joko},{Riza,Joko},{Firda,Joko}}

  8. Jenis Graph

  9. Jenis Graph • Directed Graph (Digraph) • Undirected Graph • Complete Undirected Graph • Connected Undirected Graph • Weigth Graph

  10. u • v Directed Graph (Digraph) • Graph yang memiliki orientasi/arah. • Setiap lines/edge Digraph memiliki anak panah yang mengarah ke node tertentu. • Secara notasi sisi digraph ditulis sebagai vektor (u, v). u = origin (vertex asal) v = terminus(vertex tujuan)

  11. 2 3 1 4 5 6 7 Contoh Digraph (1)

  12. Contoh Digraph (2) G = {V, E} V = {A, B, C, D, E, F, G, H, I,J, K, L, M} E = {(A,B),(A,C), (A,D), (A,F), (B,C), (B,H), (C,E), (C,G), (C,H), (C,I), (D,E), (D,F), (D,G), (D,K), (D,L), (E,F), (G,I), (G,K), (H,I), (I,J), (I,M), (J,K), (J,M), (L,K), (L,M)}.

  13. Gambar Digraph (2)

  14. u • v Undirected Graph (Digraph) • Graph yang tidak memiliki orientasi/arah. • Setiap sisi {u, v} berlaku pada kedua arah. • Misalnya : {x,y}. Arah bisa dari x ke y, atau y ke x. • Secara grafis sisi pada undigraph tidak memiliki mata panah dan secara notasional menggunakan kurung kurawal.

  15. 2 3 8 1 10 4 5 9 11 6 7 Contoh Undi-Graph (1)

  16. Contoh Undi-Graph (2) G = {V, E} V = {A, B, C, D, E, F, G, H, I,J, K, L, M} E = { {A,B},{A,C}, {A,D}, {A,F}, {B,C}, {B,H}, {C,E}, {C,G}, {C,H}, {C,I}, {D,E}, {D,F}, {D,G}, {D,K}, {D,L}, {E,F}, {G,I}, {G,K}, {H,I}, {I,J}, {I,M}, {J,K}, {J,M}, {L,K}, {L,M}}.

  17. Gambar Undi-Graph (2)

  18. n = 4 n = 1 n = 2 n = 3 Complete Undirected Graph • Semua node memiliki edge/lines untuk setiap node pada graph. n = node

  19. Connected Graph • Termasuk Jenis Undirected graph. • Setiap pasang vertex memiliki edge.

  20. 2 3 8 1 10 4 5 9 11 6 7 Contoh Connected Graph

  21. 2 3 8 1 10 4 5 9 11 6 7 Contoh Not Connected Graph

  22. 2 3 8 1 10 4 5 9 11 6 7 Connected Components

  23. Weigth Graph • Jika semua lines/edge dalam graph memiliki bobot/nilai (value).

  24. A E 2 D 2 2 4 5 B F 4 C Contoh Weigth Graph

  25. 1 2 Self-edge/loop LEGAL 3 4 5 6 7 Loop • Digraph dapat memiliki edge dari dan menuju ke node itu sendiri (Self-edge). Hal ini dikenal dengan istilah loop.

  26. Implementasi Graph

  27. 2 3 8 1 10 4 5 9 11 6 7 Aplikasi Jaringan Komunikasi • Node/Vertex = kota • Lines/Edge = communicationlink.

  28. 2 4 3 8 8 1 6 10 2 4 5 4 4 3 5 9 11 5 6 7 6 7 Peta Penelusuran Kota(Berdasarkan Jarak/Waktu) • Node/Vertex = Kota • Lines/edge = jalur • Weight = jarak/waktu

  29. 2 3 8 1 10 4 5 9 11 6 7 Peta kota • Some streets are one way.

  30. Graph Property

  31. Property • Jumlah Edge • Vertex Degree • Jumlah Vertex Degree • In-Degree • Out-Degree

  32. Jumlah Lines/Edge—Undirected Graph • Setiap lines/edge memiliki bentuk (u,v) dimana u != v. • Jumlah pasangan vertex n yang mungkin adalah n(n-1). • Jumlah lines/edge undirected graph (lebih kecil sama dengan) <= n(n-1)/2. • Selama (u,v) sama dengan (v,u) Jumlah lines/edge pada complete undi-graph adalah n(n-1)/2.

  33. Jumlah Lines/Edges—Directed Graph • Setiap lines/edge memiliki bentuk (u,v) dimana u != v. • Jumlah pasangan verteks yang mungkin untuk vertex n adalah n(n-1). • Selama edge(u,v) tidak sama dengan (u,v) dan (v,u) maka jumlah edge untuk complete directed graph adalah n(n-1). • Jumlah edge untuk directed graph (lebih kecil sama dengan) <= n(n-1).

  34. Vertex degree • Degree : Jumlah edge/lines yang dimiliki node/vertex.

  35. 2 3 8 1 10 4 5 9 11 6 7 Contoh Vertex Degree degree(2) = 2, degree(5) = 3, degree(3) = 1 degree(9) = ??? degree (11) = ???

  36. 8 10 9 11 Jumlah Vertex Degrees Jumlah Vertex degrees = 2e (eadalah jumlah edge) Jumlah Vertex Degree = 6

  37. 2 3 8 1 10 4 5 9 11 6 7 In-Degree Jumlah edge yang mengarah ke Node/Vertex. indegree(2) = 1, indegree(8) = 0, indegree(7)=???

  38. 2 3 8 1 10 4 5 9 11 6 7 Out-Degree Jumlah edge yang keluar dari Node/Vertex. outdegree(2) = 1, outdegree(8) = 2, outdegree(7) = ???

  39. Representasi Graph

  40. Representasi Graph • Adjacency Matrix • Adjacency Lists

  41. Adjacency Matrix • Direpresentasikan dengan array 2D.

  42. Adjacency Matrix • Matriks digunakan untuk himpunan adjacency setiap verteks. • Baris berisi vertex asal adjacency, sedangkan kolom berisi vertex tujuan adjacency. • Bila sisi graph tidak mempunyai bobot, maka [x, y] adjacency disimbolkan dengan 1 dan 0. • Bila sisi graph mempunyai bobot, maka [x, y] adjacency disimbolkan dengan bobot sisi tersebut.

  43. Representasi Graph

  44. Penerapan Adjacency Matriks

  45. 1 2 3 4 5 2 1 3 2 1 3 4 4 5 5 Adjacency Matrix • Representasi Matrik ordo nxn , dimana n = vertex/node • A(i,j) = 1,jika antara node i dan node j terdapat edge/terhubung. 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0

  46. 1 2 3 4 5 2 1 0 1 0 1 0 3 2 1 0 0 0 1 1 3 0 0 0 0 1 4 4 1 0 0 0 1 5 5 0 1 1 1 0 Adjacency Matrix (Undi-graph) • Diagonal entries are zero. • Adjacency matrix of an undirected graph is symmetric. • A(i,j) = A(j,i) for all i and j.

  47. 1 2 3 4 5 2 1 0 0 0 1 0 3 2 1 0 0 0 1 1 3 0 0 0 0 0 4 4 0 0 0 0 1 5 5 0 1 1 0 0 Adjacency Matrix (Digraph) • Adjacency matrix of a digraph need not be symmetric.

  48. Adjacency List • Direpresentasikan dengan linkedlist atau array. • Linked Adjacency Lists • Array Adjacency Lists

  49. 2 3 1 4 5 Array Adjacency Lists • Adjacency list for vertex i is a linear list of vertices adjacent from vertex i. • An array of n adjacency lists. aList[1] = (2,4) aList[2] = (1,5) aList[3] = (5) aList[4] = (5,1) aList[5] = (2,4,3)

  50. 2 aList[1] 2 4 3 [2] 1 5 [3] 5 1 [4] 5 1 4 aList[5] 2 4 3 5 Adjacency Lists (Linked List) • Each adjacency list is a chain.

More Related