Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik – Graphen
Dies ist ein Graph,weil er Knoten und Kantenhat!
© 2010 Manuel Friedrich - eMail: [email protected]
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Auch ein Baum istein Graph, Mann…!!!
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Ein Graph besteht aus Knoten
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Ein Baum besteht ausKnoten und Kanten.
Jede Kante verbindetzwei Knoten.
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Ein Baum besteht ausKnoten und Kanten.
Jede Kante verbindetzwei Knoten.
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Ein Knoten hat einDatenelement mitInformationen, z. B.den Namen einesKnotens.
A
F K
U H
Z B
W
M
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Ein Pfad im Graphen ist z. B. „ZUFAKW“ A
F K
U H
Z B
W
M
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Das ist ein Zyklus,wenn Start und Zielgleich sind.
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Das ist ein ungerichteter Graphohne Bewertung
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Das ist ein gerichteter Graph mit Bewertung
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Klassendiagramm
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Knotenfeldals Array
Knoten[] knotenfeld=new Knoten[7]
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Adjazenzmatrixals zweidimensionales Array
int[][] adja=new int[7][7]
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Jetzt geht es los….
Erstelle die Klasse Graph!
Wir brauchen ein Knotenfeldund eine Adjazenzmatrix!
Die maximale Anzahl soll als Pramater im Konstruktor bestimmt werden.
Setze alle Werte der Adjazenzmatrix auf -1! Das Knotenfeld bleibt erstmal leer!
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Erstelle die Klasse Knoten!
Als Attribut brauchen wir ein Datenelement daten!
Es soll einen Kontruktor mit einem Datenelement als Kontruktor geben!
Außerdem brauchen wir eine Get-Methode für das Datenelemnt.
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Nun noch die Klasse Datenelement!
Wir erstellen ein „Flugnetz“ – jedesDatenelement hat einen Ortsnamen, ein Land in dem sich der Flughafen befindet und eine Währung des Landes, alle drei Parameter sind Strings.
Die Methode ausgeben() liefert einen schönen Satz, z. B. „Der Flughafen Frankfurt liegt in Deutschland.“ In Deutschland ist die Wähung „EUR“.
Schiller-Gymnasium HofManuel Friedrich OStR, Q11 - Informatik - Graph
© 2010 Manuel Friedrich - eMail: [email protected]
Unser nächstes Ziel! Einen Knoten und Kanten hinzufügen. Welche Informationen brauchen wir dafür?
Wo müssen jetzt überall Veränderungen im Knotenfeld und in der Adjazenzmatrix vorgenommen werden?
Welche Variable(n) müssen wir einführen?