Materi 11 Teori Graf Contoh graf Peta jawa

  • Slides: 26
Download presentation
Materi 11 Teori Graf

Materi 11 Teori Graf

Contoh graf • Peta jawa tengah : sehingga – Kita tau apakah ada lintasan

Contoh graf • Peta jawa tengah : sehingga – Kita tau apakah ada lintasan jalan antar 2 kota – Rute dari satu kota ke kota lainnya melalui kota apa saja – Rute tersingkat dari kota A ke kota Z

Definisi graf • Definisi pada Graf : – V = himpunan vertex atau node

Definisi graf • Definisi pada Graf : – V = himpunan vertex atau node • V = {v 1, v 2, v 3, . . , Vn} • V dapat berupa huruf, angka atau kombinasi antar keduanya • V harus ada isinya – E = himpunan edge yang menghubungkan antar vertex • • E ={e 1, e 2, e 3, . . . , en} E = (vi, vj) E adalah edge yang menghubungkan vertex i dengan vertex j E boleh tidak ada isinya

Contoh Graf • G 1 : – V = {1, 2, 3, 4} –

Contoh Graf • G 1 : – V = {1, 2, 3, 4} – E = {(1, 2), (1, 3), (2, 4), (3, 4)} • G 2 : – V = {1, 2, 3, 4} – E = {(1, 2), (2, 3), (1, 3), (2, 4), (3, 4)} – E = { e 1, e 2, e 3, e 4, e 5, e 6, e 7} – Catt e 3 dan e 4 multiple edges/ paralel edges • G 3 : – V = {1, 2, 3, 4} – E = {(1, 2), (2, 3), (1, 3), (2, 4), (3, 3)} – E = { e 1, e 2, e 3, e 4, e 5, e 6, e 7, e 8} – Catt e 8 loop

Jenis graf berdasarkan loop atau multiple edges • Simple graf – Tidak ada loop

Jenis graf berdasarkan loop atau multiple edges • Simple graf – Tidak ada loop dan multiple edges – Tidak ada arah – Ex : saluran kable komputer dapat 2 arah • Unsimple graf – Multigraph ada multiple edges – Pseudograph ada loop, jika ditambah multiple edges, tetap Pseudograph

Introduction to Graphs • Example: A multigraph G with vertices V = {a, b,

Introduction to Graphs • Example: A multigraph G with vertices V = {a, b, c, d}, edges {1, 2, 3, 4, 5} and function f with f(1) = {a, b}, f(2) = {a, b}, f(3) = {b, c}, f(4) = {c, d} and f(5) = {c, d}: 1 4 b a 2 3 c d 5

Jenis graf berdasarkan jumlah vertex • limited graf – Jumlah vertex berhingga – dipelajari

Jenis graf berdasarkan jumlah vertex • limited graf – Jumlah vertex berhingga – dipelajari • Unlimited graf – Jumlah vertex tidak berhingga – Tidak dipelajari

Jenis graf berdasarkan orientasi arah • Undirected graf – Tidak ada penunjukan arah pada

Jenis graf berdasarkan orientasi arah • Undirected graf – Tidak ada penunjukan arah pada edge – Sehingga (vi, vj) = (vj, vi) • Directed graf – Ada penunjukan arah pada edge – Sehingga ada : • Initial vertex • Terminal vertex

Introduction to Graphs • Example: A directed multigraph G with vertices V = {a,

Introduction to Graphs • Example: A directed multigraph G with vertices V = {a, b, c, d}, edges {1, 2, 3, 4, 5} and function f with f(1) = (a, b), f(2) = (b, a), f(3) = (c, b), f(4) = (c, d) and f(5) = (c, d): 1 4 b a 2 3 c d 5

Type Edges Multiple edges ? Loops ? Simple graph undirected no no Multigraph undirected

Type Edges Multiple edges ? Loops ? Simple graph undirected no no Multigraph undirected yes no Pseudograph undirected yes Directed graph directed no yes Directed multigraph directed yes Lihat Tabel 1 – halaman 540

Contoh Terapan Graf 1. 2. 3. 4. 5. Penggambaran Peta Penggambaran jembatan Rangkaian Listrik

Contoh Terapan Graf 1. 2. 3. 4. 5. Penggambaran Peta Penggambaran jembatan Rangkaian Listrik Pengujian program Teori bahasa dan Otomata

Graph Terminology Sub bab 8. 2

Graph Terminology Sub bab 8. 2

Terminologi/istilah Graf • Adjacent/ketetanggaan : – 2 vertex bertetangga bila keduanya terhubung langsung –

Terminologi/istilah Graf • Adjacent/ketetanggaan : – 2 vertex bertetangga bila keduanya terhubung langsung – Ex : 6. 12 (a) vertex 1 bertetangga dengan vertex 2 dan 3, tapi tidak dengan 4 • Incidency/bersisian : – Edge e = (a, b ) dikatakan e berinciden dengan vertex a atau vertex b – Ex : 6. 12(a) edge (1, 2) berinsiden dengan vertex 1 dan 2, tapi edge (1, 2) tidak berinsiden dengan vertex 4

Terminologi: a v e = {u, v} u {v, w} w (b, a) b

Terminologi: a v e = {u, v} u {v, w} w (b, a) b (b, c) c u dan v adjacent b dan c adjacent v dan w adjacent b = initial vertex, adjacent to c edge e incident with c = terminal vertex, adjacent from b endpoints u dan v degree (v) = 4 in-degree (b) = deg – (b) = 1 out-degree(b) = deg +(b) = 3

Terminologi (lanjutan): v r Vertex v disebut “isolated” Vertex p disebut “pendant” q p

Terminologi (lanjutan): v r Vertex v disebut “isolated” Vertex p disebut “pendant” q p Graph di samping ini disebut “regular” (3 -regular) karena tiap vertex memiliki degree sama (3)

Terminologi (lanjutan): v q r p “Complementary graph” untuk graph di samping ini adalah

Terminologi (lanjutan): v q r p “Complementary graph” untuk graph di samping ini adalah v r q p

Terminologi/istilah Graf • Isolated vertex – Vertex yg tidak mempunyai edge • Graf kosong

Terminologi/istilah Graf • Isolated vertex – Vertex yg tidak mempunyai edge • Graf kosong – Graf yang mempunyai vertex tapi tidak mempunyai edge • Degree – – – Jumlah edge yang menyentuh vertex Loop degree = 2 Lambang d(v) Ex : 6. 12 (a) d(1) = d(4) =2 D(2) = d(3) =3

Terminologi/istilah Graf – Pendant vertex yang berderajat 1 – Pada graf yang berarah :

Terminologi/istilah Graf – Pendant vertex yang berderajat 1 – Pada graf yang berarah : • , din(v) = jumlah edge yang masuk ke vertex • , dout(v) =jumlah edge yang keluar dari vertex • Sehingga d(v) = din(v) + dout(v)

Graph Terminology • Definition: In a graph with directed edges, the indegree of a

Graph Terminology • Definition: In a graph with directed edges, the indegree of a vertex v, denoted by deg-(v), is the number of edges with v as their terminal vertex. • The out-degree of v, denoted by deg+(v), is the number of edges with v as their initial vertex. • Question: How does adding a loop to a vertex change the in-degree and out-degree of that vertex? • Answer: It increases both the in-degree and the outdegree by one.

Graph Terminology • Example: What are the in-degrees and outdegrees of the vertices a,

Graph Terminology • Example: What are the in-degrees and outdegrees of the vertices a, b, c, d in this graph: • deg-(a) = 1 • deg+(a) = 2 • deg-(d) = 2 • deg+(d) = 1 a d b • deg-(b) = 4 • deg+(b) = 2 c • deg-(c) = 0 • deg+(c) = 2

Graph Terminology • Theorem: Let G = (V, E) be a graph with directed

Graph Terminology • Theorem: Let G = (V, E) be a graph with directed edges. Then: • v V deg-(v) = v V deg+(v) = |E| • This is easy to see, because every new edge increases both the sum of in-degrees and the sum of out-degrees by one.

Teorema: G = (V, E) = directed graph = = |E| contoh: 2 b

Teorema: G = (V, E) = directed graph = = |E| contoh: 2 b a 1 3 4 c d 5

Graph Terminology • Example: Which vertices in the following graph are isolated, which are

Graph Terminology • Example: Which vertices in the following graph are isolated, which are pendant, and what is the maximum degree? What type of graph is it? d a b i c h e f g j • Solution: Vertex f is isolated, and vertices a, d and j are pendant. The maximum degree is deg(g) = 5. This graph is a pseudograph (undirected, loops).

Graph Terminology • Let us look at the same graph again and determine the

Graph Terminology • Let us look at the same graph again and determine the number of its edges and the sum of the degrees of all its vertices: d a b i c h e f g j • Result: There are 9 edges, and the sum of all degrees is 18. This is easy to explain: Each new edge increases the sum of degrees by exactly two.

Istilah graf • The Handshaking Theorem : – Jumlah degree semua vertex adalah genap,

Istilah graf • The Handshaking Theorem : – Jumlah degree semua vertex adalah genap, yaitu 2 x edge – Dikatakan handshaking karena seperti jabat tangan, tiap edge pasti dihitung 2 kali, karena mempunyai 2 vertex, sehingga seperti orang berjabat tangan – Ex : 6. 12 (a) : • Edge = 5 • Sehingga jumlah degree semua vertex adalah 2 x 5 = 10 • , d(1) + d(2) + d(3) + d(4) = 2 + 3 + 2 = 10

Istilah graf • Karena adanya teori handshaking, maka didapat teorema baru yaitu : –

Istilah graf • Karena adanya teori handshaking, maka didapat teorema baru yaitu : – Untuk sembarang graf, banyaknya vertex yang berderajat ganjil adalah genap • Path / lintasan – Serangkaian vertex atau gabungan vertex dengan edge – Simple path dimana semua edge dilewati hanya 1 kali – Closed walk / cycle / circuit path yang berawal dan berakhir pada simpul yang sama – Open walk path yang berawal dan berakhir pada simpul yang tidak sama – Ex : 6. 12 (a) • Path 1, 2, 4, 3 adalah simple path dan open walk, panjang path = 3 • Path 1, 2, 4, 3, 1 adalah simple path dan colse walk, panjang path = 4 – Panjang path jumlah edge pada path tersebut – Jika ada multiple edge, maka penulisannya adalah penggabungan antara vertex dan edge 1 e 1 3 e 4 5 e 8