Professional Documents
Culture Documents
S = { X, {Rm} }
dr hab. inż. Zbigniew Tarapata, prof. WAT
• W, U – zbiory
• PW×U×W
✓ Własności relacji P :
1. x, u , y P
uU x, yW
2. x, u, y P v, u, z P
uU x, y,v, zW
x v y z x z y v
a
a
Rodzaje gałęzi grafu
✓Rodzaje gałęzi grafu
~ – krawędzie: x, u, y P y, u, x P x y
U
dr hab. inż. Zbigniew Tarapata, prof. WAT
U – łuki: x, u, y P y, u, x P
o
U – pętle: x, u, y P x = y
~ o
U U U U
Przykład grafu
W = 1, 2, 3, 4, 5, 6
~ o
U = a, b, c, d, e, f, g, h, i, j, k = U U U
~
U ={ d, e, f }
-wierzchołki
U ={ a, b, c, g, h, j}
dr hab. inż. Zbigniew Tarapata, prof. WAT
o -krawędzie
U ={ i, k }
- łuki
P = 3, a, 1,1, b, 3,1, c, 2,1, d, 2,2, d, 1,
2, e, 4,4, e, 2, 2, f, 4,4, f, 2, - pętle
a b f e
Grafy skończone: g k
3 4 6
W U h i
Modelowanie obiektów rzeczywistych z wykorzystaniem grafów
✓ Za pomocą grafu możemy opisywać (modelować) wszelkiego
rodzaju obiekty rzeczywiste (obiekty fizyczne, zjawiska, procesy
itp.), które posiadają pewne cechy (wierzchołki grafu) i pewne
relacje między cechami (gałęzie grafu);
dr hab. inż. Zbigniew Tarapata, prof. WAT
A b G A(G ) : 1
dr hab. inż. Zbigniew Tarapata, prof. WAT
𝐀𝑏 𝐺
np.:
a2,e1 a2,e3 a2,e4 1
a2,e2 a2,e5 a2,e6 0
Macierzowe reprezentacje grafu
✓ Binarna macierz
incydencji:
dr hab. inż. Zbigniew Tarapata, prof. WAT
a b c d e f g h i j k
1 1 1 1 1 0 0 0 0 0 0 0
2 0 0 1 1 1 1 0 0 0 1 0
3 1 1 0 0 0 0 1 1 0 0 0
A b (G )
4 0 0 0 0 1 1 1 1 1 0 0
5 0 0 0 0 0 0 0 0 0 1 0
6 0 0 0 0 0 0 0 0 0 0 1
Macierzowe reprezentacje grafu
✓ Macierz przyległości wierzchołków:
R G rx , y
W W
rx , y u U : x , u , y P y , u , x P
dr hab. inż. Zbigniew Tarapata, prof. WAT
0 2 2 0 0 0
2 0 0 2 1 0
2 0 0 2 0 0
R (G )
0 2 2 1 0 0
0 1 0 0 0 0
0 0 0 0 0 1
R b G rx , y
b
W W
b
1 rx , y 0
dr hab. inż. Zbigniew Tarapata, prof. WAT
rx, y
0 1 1 0 0 0
1 0 0 1 1 0
1 0 0 1 0 0
R b (G )
0 1 1 1 0 0
0 1 0 0 0 0
0 0 0 0 0 1
✓ Macierz przyległości gałęzi:
BG A Tb G A b G
Macierzowe reprezentacje grafu
✓ Macierz przejść:
P G px , y
W W
px , y u U : x, u, y P
dr hab. inż. Zbigniew Tarapata, prof. WAT
0 2 1 0 0 0
1 0 0 2 0 0
1 0 0 2 0 0
P(G )
0 2 0 1 0 0
0 1 0 0 0 0
0 0 0 0 0 1
✓ Binarna macierz przejść: Pb G p xb, y W W
p xb, y 1 p x , y 0
Macierzowe reprezentacje grafu: porównanie
a b c d e f g h i j k
1 1 1 1 1 0 0 0 0 0 0 0
2 0 0 1 1 1 1 0 0 0 1 0
3 1 1 0 0 0 0 1 1 0 0 0
A b (G )
4 0 0 0 0 1 1 1 1 1 0 0
dr hab. inż. Zbigniew Tarapata, prof. WAT
5 0 0 0 0 0 0 0 0 0 1 0
6 0 0 0 0 0 0 0 0 0 0 1
0 2 2 0 0 0 0 2 1 0 0 0
2 0 1
0 0 2 1
0 0 2 0 0
2 0 0 2 0 0 1 0 0 2 0 0
R (G ) P(G )
0 2 2 1 0 0 0 2 0 1 0 0
0 1 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 1
0 1 1 0 0 0 0 1 1 0 0 0
1 1 0
0 0 1 1 0 0 0 1 0
1 0 0 1 0 0 1 0 0 1 0 0
R b (G ) Pb (G )
0 1 1 1 0 0 0 1 0 1 0 0
0 1 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 1
dr hab. inż. Zbigniew Tarapata, prof. WAT
Graf jako struktura danych w informatyce
dr hab. inż. Zbigniew Tarapata, prof. WAT
Reprezentacje grafu w pamięci komputera: graf nieskierowany
x, y u U : x, u , y P
x, y u U : x, u , y P
~
✓ Krotność grafu: K G max V , ,
V max x, y
x , y W W
max x, y
x , y W W
max x, y
x , y W W
Rodzaje grafów
✓ Graf G = W, U, P jest rodzaju (lub należy do klasy):
V , , V V
V , , N 0
dr hab. inż. Zbigniew Tarapata, prof. WAT
✓ Unigraf: K G 1
(1) Graf zdegenerowany (2) Graf pusty (3) Multigraf (K(G) = 2 > 1)
x, y V x, y x, x
dr hab. inż. Zbigniew Tarapata, prof. WAT
x,yW xW
x y
Trzy (5-, 4- i 3-
wierzchołkowe) grafy
pełne w klasie: 1, 0, 0
(tzw. kliki)
Rodzaje grafów
✓ Graf zwykły:
o
1,0,0 = unigraf niezorientowany, bez pętli,
tzn. U U , K G 1
Inna definicja:
G W ,U , U x, y W
dr hab. inż. Zbigniew Tarapata, prof. WAT
Inne definicje:
G W ,U G W,
1) 2)
U W W : W 2W , y x x, y U
✓ Grafy Berge’a:
Rodzaje grafów
✓ Graf dwudzielny:
G W1 W2 ,U , P przy czym W1 W2 oraz
x y
Dlaczego ten
graf nie jest
grafem Königa?
Algorytm
n 100 w przypadku
udostępniania
komputera na
okres
Symbol Autor [rok] Złożoność minuty godziny
Kuratowski
A1
[1930] cn6 325 lat 4 8
Goldstein
A2
[1963] cn3 2.8 godzin 18 71
Lempel et al.
A3
[1967] cn2 100 sekund 77 6 000
A4
Hopcroft- cn log 2 n 7 sekund 643 24 673
Tarjan [1971]
Hopcroft- cn
A5 1 sekunda 6 000 36 10 4
Tarjan [1974]
Części grafów
✓ Część grafu G W ,U , P : G ' W ',U ', P ' , że
1. G' - graf
2. W ' W U ' U
dr hab. inż. Zbigniew Tarapata, prof. WAT
3. x , u, y P ' x , u, y P
x ,u , y W ' U ' W '
Części grafów
✓ Podgraf grafu G: taki graf G ' W ' , U ' , P' , że
1. G’ - część grafu G
2. x, u, y P u U '
dr hab. inż. Zbigniew Tarapata, prof. WAT
Część grafu G
(jedna z możliwych)
1 2 1 2
G
3
3 G1 5
4 5
1 2 1 2 1 2
3
G2 G3 G4 5
3 5 4 5 3
Podgraf grafu G Graf częściowy grafu G Podgraf częściowy grafu G
(jeden z możliwych) (jeden z mozliwych) (graf częściowy podgrafu
G2 grafu G)
DZIĘKUJĘ ZA UWAGĘ
dr hab. inż. Zbigniew Tarapata, prof. WAT