Temanggung Purwodadi
Salatiga
Wonosobo
Purbalingga
Purwokerto
Sragen
Banjarnegara Boyolali Solo
Kroya Sukoharjo
Cilacap Kebumen Magelang
Klaten
Purworejo
Wonogiri
A D
3
Graf G = (V, E), yang dalam hal ini:
V = himpunan tidak-kosong dari simpul-simpul (vertices)
= { v1 , v2 , ... , vn }
E = himpunan sisi (edges) yang menghubungkan sepasang
simpul
= {e1 , e2 , ... , en }
4
1 1 1
e1 e4 e1 e4
e3 e3
e2 e2
2 3 2 3 2 e8
e6 e6 3
e5 e5
e7 e7
4 4 4
G1 G2 G3
Gambar 2. (a) graf sederhana, (b) graf ganda, dan (c) graf semu
G1 G2 G3
Gambar 2. (a) graf sederhana, (b) graf ganda, dan (c) graf semu
7
• Berdasarkan orientasi arah pada sisi, maka secara umum graf
dibedakan atas 2 jenis:
1. Graf tak-berarah (undirected graph)
Graf yang sisinya tidak mempunyai orientasi arah disebut
graf tak-berarah. Tiga buah graf pada Gambar 2 adalah
graf tak-berarah.
8
1 1
2 3 2 3
4 4
(a) G4 (b) G5
9
1. Rangkaian listrik.
B B
A C A C
F F
E D E D
(a) (b)
10
2. Isomer senyawa kimia karbon
metana (CH4) etana (C2H6) propana (C3H8)
H C H
11
3. Transaksi konkuren pada basis data terpusat
Transaksi T0 menunggu transaksi T1 dan T2
Transaksi T2 menunggu transaksi T1
Transaksi T1 menunggu transaksi T3
Transaksi T3 menunggu transaksi T2
T1
T3
T0
T2
deadlock!
12
4. Pengujian program
read(x);
while x <> 9999 do
begin
if x < 0 then
writeln(‘Masukan tidak boleh negatif’)
else
x:=x+10;
read(x);
end;
writeln(x);
1 2
6 7
3
Keterangan: 1 : read(x) 5 : x := x + 10
2 : x <> 9999 6 : read(x)
3:x<0 7 : writeln(x)
4 : writeln(‘Masukan tidak boleh negatif’);
13
5. Terapan graf pada teori otomata.
Mesin jaja (vending machine)
10
P P P 10
5
5
5 5
10
a b c d
10
Keterangan:
a : 0 sen dimasukkan
b : 5 sen dimasukkan
c : 10 sen dimasukkan
d : 15 sen atau lebih dimasukkan
14
Gambarkan graf yang menggambarkan
sistem pertandingan ½ kompetisi (round-
robin tournaments) yang diikuti oleh 6 tim.
15
Course : Linear and Discrete Mathematics
Effective Period : September 2022
Session 13-14
Acknowledgement
2
Learning Objectives
4 Matrix
Representation of
Shortest Path
Graphs
Algorithm
Graph
In this lesson, we study about Graph Theory and Trees.
The discussion concepts such as the degree of a
vertex,Euler and Hamiltonian circuits, properties of
rooted trees spanning trees, and shortest paths in graphs
Let n be a positive
integer. A complete
graph on n vertices,
denoted 𝐾𝑛 is a
simple
graph with n vertices A bipartite graph, also called a
and exactly one edge bigraph, is a set of graph vertices
connecting each pair decomposed into two disjoint
of distinct vertices. sets such that no two graph
vertices within the same set are
adjacent. It’s denoted by 𝐾𝑚,𝑛 .
Example graph 𝐾3,2 and 𝐾3,3
Order, size, and degree of
graph
The order of a graph G is the cardinality of its
vertex set, it’s denoted by |𝑉 𝐺 |. The order of
graph 𝐾4 is |𝑉 𝐺 | = 4.
A Trail from 𝑣 to 𝑤 is a walk from v to w that does not contain a repeated edge.
A Closed walk is a walk that starts and ends at the same vertex.
Circuit is a closed walk that contains at least one edge and does not contain a
repeated edge.
A Simple circuit is a circuit that does not have any other repeated vertex except the
first and last.
Walk (Lintasan)
Example 1:
What are the chromatic numbers of the graphs G and H shown in Figure
below
𝜒(G)=3
𝜒(H)=4
16
The Chromatic number of Kn
𝜒(Kn) = n
Example :
𝜒(K5) = 5
A coloring of K5.
17
The chromatic number of the
complete bipartite graph Km,n
The number of colors needed may seem to depend on m and n.
Because edges connect only a vertex from the set of m vertices and a
vertex from the set of n vertices, no two adjacent vertices have the
same color.
𝜒(Km,n) = 2.
Example :
𝜒(K3,4) = 2.
A coloring of K3,4.
18
The chromatic number of the
graph Cn, where n ≥ 3
𝜒(C6) = 2 𝜒(C5) = 3
19
Vertex Coloring by The Welch-Powell
Algorithm
4. Go down the list and color every vertex not connected to the
colored vertices above the same color. Then cross out all colored
vertices in the list.
Check If a graph 𝐺 has a Hamiltonian circuit, then 𝐺 has a subgraph 𝐻 with the
following
properties:
1. 𝐻 contains every vertex of 𝐺.
2. 𝐻 is connected.
3. 𝐻 has the same number of edges as vertices.
4. Every vertex of 𝐻 has degree 2.
Theorems For any positive integer 𝑛, if 𝐺 is a connected graph with 𝑛 vertices and
𝑛 − 1 edges,
then 𝐺 is a tree.
Example
It has circuit
Tree
Spanning Tree
Definition
A spanning tree for a graph 𝐺 is a subgraph of 𝐺 that contains every vertex of
𝐺 and is a tree.
Proposition
1. Every connected graph has a spanning tree.
2. Any two spanning trees for a graph have the same number of edges.
Example Solution
Find all spanning trees for the The graph G has one circuit 𝑣2𝑣1𝑣4𝑣2, and removal
graph 𝐺 pictured below. of any edge of the circuit gives a tree.
𝐺
Minimum Spanning Tree
A weighted graph is a graph for which each edge has an associated positive real number
weight.
The sum of the weights of all the edges is the total weight of the graph.
A minimum spanning tree for a connected weighted graph is a spanning tree that has the
least possible total weight compared to all other spanning trees for the graph.
In 1956 and 1957 Joseph B. Kruskal and Robert C. Prim each described much more
efficient algorithms to construct minimum spanning trees.
Kruskal’s Algorithm