mirror of
https://codeberg.org/qg-info-unterricht/zpg-graphentester.git
synced 2026-03-25 04:58:24 +01:00
Fetch Upstream v7.4 - 01/2025
This commit is contained in:
parent
09967a1c1b
commit
667bc4638b
68 changed files with 2772 additions and 2770 deletions
|
|
@ -8,7 +8,7 @@ import graph.*;
|
|||
/**
|
||||
* Dieser Algorithmus findet eine topologische Sortierung des Graphen.
|
||||
*
|
||||
* @version 1.0 from 10.12.2020
|
||||
* @version 7.1 from 12.02.2025
|
||||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public class GraphAlgo_toplogischeSortierung extends GraphAlgo {
|
|||
|
||||
|
||||
// Anfang Methoden
|
||||
public void fuehreAlgorithmusAus() {
|
||||
public void fuehreAlgorithmusAus() throws InterruptedException {
|
||||
String reihenfolge = "";
|
||||
if (g.getAnzahlKnoten()==0) {
|
||||
return;
|
||||
|
|
@ -43,26 +43,28 @@ public class GraphAlgo_toplogischeSortierung extends GraphAlgo {
|
|||
info("Sortiere die noch nicht markierten Knoten nach ihrem Wert");
|
||||
Knoten k = knoten.get(0);
|
||||
k.setMarkiert(true);
|
||||
info("Nimm Knoten "+g.getKnoteninfo(k,false)+" und markiere ihn.");
|
||||
info("Nimm Knoten mit dem geringsten Wert: "+g.getKnoteninfo(k,false)+" und markiere ihn.");
|
||||
|
||||
if(k.getIntWert() != 0) {
|
||||
melde("Fehler: Wert ist nicht 0 - Zyklus vorhanden");
|
||||
melde("Fehler: Wert ist nicht 0 - Zyklus vorhanden - Keine topologische Sortierung möglich");
|
||||
knoten.clear();
|
||||
return;
|
||||
} else {
|
||||
reihenfolge += " "+g.getKnoteninfo(k, false);
|
||||
info("Füge ihn der Liste hinzu: "+reihenfolge);
|
||||
knoten.remove(k);
|
||||
info("Reduziere den Wert aller Nachbarn von "+g.getKnoteninfo(k,false)+" um 1");
|
||||
infoIndentMore();
|
||||
for(Knoten k2 : g.getNachbarknoten(k)) {
|
||||
k2.setWert(k2.getIntWert()-1);
|
||||
info("Setze "+g.getKnoteninfo(k2, false)+" auf "+k2.getIntWert());
|
||||
}
|
||||
info("Reduziere den Wert aller Nachbarn von Knoten "+g.getNummer(k)+" um 1");
|
||||
infoIndentLess();
|
||||
}
|
||||
step();
|
||||
}
|
||||
melde("Topologische Sortierung: "+reihenfolge);
|
||||
|
||||
|
||||
} // end
|
||||
|
||||
// Ende Methoden
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue