1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of...
-
Upload
ortwin-gerdts -
Category
Documents
-
view
103 -
download
1
Transcript of 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of...
![Page 1: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/1.jpg)
1
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Graphen (1)
![Page 2: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/2.jpg)
2
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Bezeichnungen
V Menge der Knoten (vertices)|V| Anzahl der KnotenE Menge der Kanten (edges)|E| Anzahl der KantenG Graph G = (V,E)(v,w) Kante von v nach w
![Page 3: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/3.jpg)
3
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Eigenschaften
gerichtet (directed) ungerichtet (undirected)gewichtet (weighted)ungewichtet (unweighted)zyklisch (cyclic) zyklenfrei (acyclic)
vollständig (complete)bipartit (bipartite)
gerichtete Graphen:schwach zusammenhängend (weakly connected)stark zusammenhängend (strongly connected)
ungerichtete Graphen:zusammenhängend (connected)zweifach zusammenhängend (biconnected)
![Page 4: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/4.jpg)
4
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Beispiel:
ungerichtet ungewichtet vollständig zweifach zusammenhängend zyklisch nicht planar
![Page 5: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/5.jpg)
5
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Beispiel:
gerichtet ungewichtet schwach zusammenhängend zyklenfrei planar
![Page 6: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/6.jpg)
6
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Beispiel:
gerichtet gewichtet stark zusammenhängend zyklisch planar
![Page 7: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/7.jpg)
7
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Adjazenzmatrix Bsp: gerichteter und gewichteter
Graph
![Page 8: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/8.jpg)
8
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Adjazenzmatrix Bsp: ungerichteter gewichteter
Graph
![Page 9: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/9.jpg)
9
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Adjazenzmatrix Bsp: ungerichteter ungewichteter
Graph
![Page 10: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/10.jpg)
10
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
AdjazenzlistenBsp: gerichteter Graph
b
c
d
e
a
g
f
b c
d
d
e
f g
g
5 3
2
3
5
2
3
4
![Page 11: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/11.jpg)
11
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
AdjazenzlistenBsp: ungerichteter Graph
b
c
d
e
a
g
f
b c
d
d
e
f g
g
5 3
2
3
5
2
3
4
a 5
a 3
b 2 c 3
d 5
e 2
f 3e 4
![Page 12: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/12.jpg)
12
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Implementierung eines Graphen
class Graph {Vector nodes = new Vector();void clearNodes() {
for (int i=0; i<nodes.size(); i++) {Node node = (Node)nodes.elementAt(i);node.setVisited(false);
}}void depthFirst()...void breadthFirst()...
}
![Page 13: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/13.jpg)
13
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Implementierung der Knoten
class Node {boolean visited = false;Vector edges = new Vector();
boolean isVisited() {return visited;}void setVisited(boolean p) {visited = p;}void depthFirst()...void breadthFirst()...
}
![Page 14: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/14.jpg)
14
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Implementierung der Kanten
class Edge {int weight;Node to;Edge(int weight, Node to) {
this.weight = weight;this.to= to;
}}
![Page 15: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/15.jpg)
15
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (rekursiv)
class Graph {...
void depthFirst() {clearNodes();for (int i=0; i<nodes.size(); i++) {
Node node = (Node)nodes.elementAt(i);if (!node.isVisited())
node.depthFirst();}
}}
![Page 16: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/16.jpg)
16
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (rekursiv) O(|V|+|E|)
class Node {...
void depthFirst() {if (isVisited()) return;visit(this);setVisited(true);for (int i=0; i<edges.size(); i++) {
Edge edge = (Edge)edges.elementAt(i); edge.to.depthFirst();
}}
}
![Page 17: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/17.jpg)
17
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (1)
1. Schritt:Start mit a
2. Schritt: weiter
von a nach b
3. Schritt: weiter
von b nach d
4. Schritt: weiter
von d nach c
a wird markiert
b wird markiert
d wird markiert
c wird markiert
![Page 18: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/18.jpg)
18
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (2)
5. Schritt: stop
a ist markiert!
Vorsicht Zyklus!
6. Schritt: zurück von c nach d(c,d) wird
Baumkante
7. Schritt: weiter
von d nach e
c ist fertig
8. Schritt: weiter
von e nach f
e wird markiert
f wird markiert
![Page 19: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/19.jpg)
19
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (3)
g wird markiert
9. Schritt: weiter
von f nach g
10. Schritt: stop
e ist markiert!
Vorsicht Zyklus!
11. Schritt: zurück
von g nach f(f,g) wird
Baumkante
12. Schritt: zurück
von f nach e(e,f) wird
Baumkante
![Page 20: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/20.jpg)
20
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Tiefensuche (4)
13. Schritt: zurück
von e nach d(d,e) wird
Baumkante
14. Schritt: zurück
von d nach b(b,d) wird
Baumkante
15. Schritt: zurück
von b nach a(a,b) wird
Baumkante
16. Schritt: fertigals Ergebnis
entstehtein spannender
Baum!
![Page 21: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/21.jpg)
21
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich Tiefensuche (iterativ)
void depthFirst() {Stack stack = new Stack();clearNodes();for (int i=0; i<edges.size(); i++) {
Node start = (Node)nodes.elementAt(i); if (!start.isVisited()) {
start.setVisited(true);stack.push(start);do {
Node node = (Node)stack.pop();visit(node);for (int j=node.edges.size()-1; j>=0; j--) {
Edge edge = (Edge)node.edges.elementAt(j);if (!edge.to.isVisited()) {
edge.to.setVisited(true);stack.push(edge.to);
}}
} while (!stack.isEmpty())}
}}
![Page 22: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/22.jpg)
22
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Breitensuche (iterativ) O(|V|+|E|)
void breadthFirst() {Queue queue = new Queue();clearNodes();for (int i=0; i<edges.size(); i++) {
Node start = (Node)nodes.elementAt(i); if (!start.isVisited()) {
start.setVisited(true);queue.put(start);do {
Node node = (Node)queue.get();visit(node);for (int j=0; j<node.edges.size(); j++) {
Edge edge = (Edge)node.edges.elementAt(j);if (!edge.to.isVisited()) {
edge.to.setVisited(true);queue.put(edge.to);
}}
} while (!queue.isEmpty())}
}}
![Page 23: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/23.jpg)
23
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Breitensuche (1)
1. Schritt:Start mit a
2. Schritt: [] (a,b)
3. Schritt: [(a,b)]
(a,c)
4. Schritt: (a,b) [(a,c)](a,b) wird
Baumkante
a wird markiert
b wird markiert
c wird markiert
![Page 24: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/24.jpg)
24
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Breitensuche (2)
6. Schritt: (a,c) [(b,d)](a,c) wird
Baumkante
5. Schritt: [(a,c)] (b,d)
8. Schritt: (b,d) [](b,d) wird
Baumkante
d wird markiert
7. Schritt:d ist markiert Vorsicht Zyklus!
![Page 25: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/25.jpg)
25
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Breitensuche (3)
10. Schritt: (d,e) [](d,e) wird
Baumkante
9. Schritt: [] (d,e)
11. Schritt: [] (e,f)
e wird markiert
12. Schritt: [(e,f)] (e,g)
f wird markiert
g wird markiert
![Page 26: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/26.jpg)
26
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Breitensuche (4)
14. Schritt:g ist markiert Vorsicht Zyklus!
13. Schritt: (e,f) [(e,g)](e,f) wird
Baumkante
15. Schritt: (e,g) [](e,g) wird
Baumkante
16. Schritt: f ist markiert Vorsicht Zyklus!
![Page 27: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/27.jpg)
27
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Spannender Baum als Ergebnis der Breitensuche
![Page 28: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/28.jpg)
28
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Traversieren eines ungerichteten Graphen:
Kanten die zu einem bereits markierten Knoten führen kennzeichnen einen Zyklus!
![Page 29: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/29.jpg)
29
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Traversieren eines ungerichteten Graphen:
Alle von einem Startknoten aus erreichbaren Knoten gehören zur gleichen Komponente!
![Page 30: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/30.jpg)
30
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Rekursive Tiefensuche in gerichteten Graphen:
Kanten die zu einem aktiven (blau) markierten Knoten führen kennzeichnen einen Zyklus!
![Page 31: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/31.jpg)
31
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Rekursive Tiefensuche in gerichteten Graphen:
Kanten die zu einem (rot) markierten Baum-Knoten führen kennzeichnen keinen Zyklus!
![Page 32: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/32.jpg)
32
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Minimum Spanning Tree (Dijkstra/Prim)
Ermittlung eines minimalen spannenden Baumes eines gewichteten Graphens nach Dijkstra/Prim
O(|E| log |V|)
Breitensuche unter Verwendung einer PriorityQueue (geringes Gewicht hat hohe Priorität) liefert einen minimalen spannenden Baum!
![Page 33: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/33.jpg)
33
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra/Prim (1)
1. Schritt:Start mit a
2. Schritt: [] (a,b,5)
3. Schritt: [(a,b,5)]
(a,c,3)
4. Schritt: (a,c,3)
[(a,b,5)]
![Page 34: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/34.jpg)
34
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra/Prim (2)
5. Schritt:[(a,b,5)]
(c,d,3)
6. Schritt: (c,d,3)
[(a,b,5)]
7. Schritt: [(a,b,5)] (d,b,2)(d,b,2) ersetzt
(a,b,5)
8. Schritt: [(d,b,2)]
(d,e,5)
![Page 35: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/35.jpg)
35
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra/Prim (3)
9. Schritt:(d,b,2)
[(d,e,5)]
10. Schritt: (d,e,5) []
11. Schritt: [] (e,f,2)
12. Schritt: [(e,f,2)]
(e,g,4)
![Page 36: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/36.jpg)
36
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra/Prim (4)
13. Schritt:(e,f,2)
[(e,g,4)]
14. Schritt: [(e,g,4)] (f,g,3)(f,g,3) ersetzt
(e,g,4)
15. Schritt:(f,g,3) [] fertig
![Page 37: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/37.jpg)
37
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Minimum Spanning Tree (Kruskal)
Ermittlung eines minimalen spannenden Baumes eines gewichteten Graphens nach Kruskal
O(|E| log|E|)
Entfernen sämtlicher Kanten (führt zu einem Graphen mit |V| isolierten Knoten). Hinzufügen jener Kanten in nach Gewichten steigend sortierter Reihenfolge die die Anzahl der Komponenten verringern.
![Page 38: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/38.jpg)
38
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (1)
b≠d union(b,d)
Die Knoten b und d befinden sich in unterschiedlichen Komponenten.
Die Kante (b,d) verbindet die beiden isolierten Knoten b und d
![Page 39: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/39.jpg)
39
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (2)
e≠f union(e,f)
Die Knoten e und f befinden sich in unterschiedlichen Komponenten.
Die Kante (e,f) verbindet die beiden isolierten Knoten e und f
![Page 40: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/40.jpg)
40
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (3)
a≠c union(a,c)
Die Knoten a und c befinden sich in unterschiedlichen Komponenten.
Die Kante (a,c) verbindet die beiden isolierten Knoten a und c
![Page 41: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/41.jpg)
41
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (4)
c≠d union(c,d)
Die Knoten c und d befinden sich in unterschiedlichen Komponenten.
Die Kante (c,d) verbindet die beiden Komponenten ac und bd
![Page 42: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/42.jpg)
42
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (5)
f≠g union(f,g)
Die Knoten f und g befinden sich in unterschiedlichen Komponenten.
Die Kante (f,g) verbindet die Komponente ef und den isolierten Knoten g
![Page 43: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/43.jpg)
43
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (6)
e=g
Die Knoten e und g befinden sich in derselben Komponente efg.
Die Kante (e,g) ist nicht Bestandteil des minimalen spannenden Baumes!
![Page 44: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/44.jpg)
44
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (7)
a=b
Die Knoten a und b befinden sich in derselben Komponente abcd.
Die Kante (a,b) ist nicht Bestandteil des minimalen spannenden Baumes!
![Page 45: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/45.jpg)
45
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kruskal (8)
d≠e union(d,e)
Die Knoten d und e befinden sich in unterschiedlichen Komponenten.
Die Kante (d,e) verbindet die Komponente abcd und efg
![Page 46: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/46.jpg)
46
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Ermittlung aller von einem Startknoten ausgehenden kürzesten Wege eines gewichteten Graphens
nach Dijkstra O(|E| log|V|)
Breitensuche unter Verwendung einer PriorityQueue (geringe Entfernung vom Startknoten hat hohe Priorität) ordnet jedem Knoten den kürzesten Weg vom Startknoten zu!
![Page 47: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/47.jpg)
47
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra (1)
1. Schritt:Start mit a
2. Schritt: [] (a,b,5)
3. Schritt: [(a,b,5)]
(a,c,3)
4. Schritt: (a,c,3)
[(a,b,5)]
![Page 48: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/48.jpg)
48
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra (2)
5. Schritt:[(a,b,5)]
(c,d,6)
6. Schritt: (a,b,5)
[(c,d,6)]
7. Schritt: [(c,d,6)] (b,d,7) > (c,d,6)
8. Schritt: (c,d,6) []
![Page 49: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/49.jpg)
49
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra (3)
9. Schritt:[] (d,e,11)
10. Schritt: (d,e,11) []
11. Schritt: [] (e,f,13)
12. Schritt: [(e,f,13)]
(e,g,15)
![Page 50: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/50.jpg)
50
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra (4)
13. Schritt:(e,f,13)
[(e,g,15)]
14. Schritt: [(e,g,15)] (f,g,16) > (e,g,15)
15. Schritt:(e,g,15) [] fertig
![Page 51: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/51.jpg)
51
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Dijkstra (5) Alle kürzesten Wege von a:
a-c 3 a-c-d-e-g 15
a-c-d-e-f 13
a-c-d-e 11
a-c-d 6a-b 5
![Page 52: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/52.jpg)
52
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Transitive Hülle
Adjazenzmatrix a: boolean a[][] = new boolean[n][n];
Transitive Hülle: All i,j,k: 0≤i,j,k<n: a[i][k] and a[k][j] a[i][j]
i
k
j
aik akj
![Page 53: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/53.jpg)
53
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Transitive HülleAlgorithmus von Warshall
O(|V|3)
for (int k=0; k<n; k++)for (int i=0; i<n; i++)for (int j=0; j<n; j++)if (a[i][k] && a[k][j]) a[i][j] = true;
oder
a[i][j] = a[i][j] || (a[i][k] && a[k][j]);
![Page 54: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/54.jpg)
54
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Kürzeste WegeAlgorithmus von Floyd
O(|V|3)
Adjazenzmatrix a: double a[][] = new double[n][n];
aij ... Entfernung von i nach j
aij = ∞ falls kein Weg von i nach j
for (int k=0; k<n; k++)for (int i=0; i<n; i++)
for (int j=0; j<n; j++)a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
![Page 55: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/55.jpg)
55
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Floyd (1)
Adjazenzmatrix es führt kein Weg übera
a - c -d (6)< a - b -d (7)
a - b -d (7)
![Page 56: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/56.jpg)
56
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Floyd (2)
a -c -d -e (11)
b -d -e (7) c -d -e (8) a - c -d -e -f (13)
![Page 57: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/57.jpg)
57
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Floyd (3)
a - c -d -e -g (15)
b -d -e -f (9) b -d -e -g (11) c -d -e -f (10)
![Page 58: 1 Helmut Schauer Educational Engineering Lab Department for Information Technology University of Zurich Graphen (1)](https://reader036.fdocuments.in/reader036/viewer/2022070310/55204d7f49795902118d1415/html5/thumbnails/58.jpg)
58
Helmut SchauerEducational Engineering LabDepartment for Information TechnologyUniversity of Zurich
Floyd (4)
d -e -f (7) d -e -g (9)