Fetch Upstream v7.4 - 01/2025

This commit is contained in:
Max Mustermann 2026-03-17 08:43:07 +01:00
parent 09967a1c1b
commit 667bc4638b
68 changed files with 2772 additions and 2770 deletions

View file

@ -14,7 +14,7 @@ import javafx.application.Platform;
* Abstrakte Oberklasse für alle zu simulierende Algorithmen
* Diese müssen die Methode getBezeichnung(): String und fuehreAlgorithmusAus() überschreiben.
*
* @version 6.7 (Dez. 2020)
* @version 7.1 12.02.2025
* @author Thomas Schaller
*/
@ -78,10 +78,9 @@ public abstract class GraphAlgo extends Thread {
/**
* Muss vom Algorithmus aufgerufen werden, um einen Haltepunkt zu setzen
*/
public void step() {
public void step() throws InterruptedException {
if(gp == null) return;
try{
//System.out.println("Step");
gp.updateImage();
aktuellerZustand = g.getStatus();
waitforclick = true;
@ -95,9 +94,13 @@ public abstract class GraphAlgo extends Thread {
if (hilfe != null) hilfe.setReviewAllowed(false);
g.setStatus(aktuellerZustand);
aktuellerZustand = null;
if(Thread.interrupted()){
throw new InterruptedException();
}
}catch(Exception e) {
// Erneutes Stop, damit nicht stop während des Sleeps hier abgefangen wird.
stop();
//System.out.println("Step wurde unterbrochen");
throw e;
}
}
@ -146,17 +149,13 @@ public abstract class GraphAlgo extends Thread {
if (hilfe != null) hilfe.setReviewAllowed(false);
fuehreAlgorithmusAus();
gp.updateImage();
// System.out.println("Algorithmus beendet");
} catch( ThreadDeath e){
// System.out.println("Algorithmus vorzeitig beendet."+e);
//System.out.println("Algorithmus beendet");
} catch( InterruptedException e){
//System.out.println("Algorithmus vorzeitig beendet."+e);
} finally {
if (hilfe != null) hilfe.setReviewAllowed(true);
inArbeit = false;
}
if (hilfe != null) hilfe.setReviewAllowed(true);
inArbeit = false;
return;
}
else
{
return;
}
}
// Ende Methoden
@ -184,7 +183,7 @@ public abstract class GraphAlgo extends Thread {
/**
* Methode für den eigentlichen Algorithmus
*/
public abstract void fuehreAlgorithmusAus();
public abstract void fuehreAlgorithmusAus() throws InterruptedException;
/**
* Name des Algorithmus für die Dropdown-Auswahl
@ -257,3 +256,4 @@ public abstract class GraphAlgo extends Thread {
}
}

View file

@ -9,7 +9,7 @@ import graph.*;
* Dieser Algorithmus findet die kürzesten Pfade in einem gewichteten Graphen.
* Algorithmus: Bellman-Ford
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -37,7 +37,7 @@ public class GraphAlgo_BellmanFord extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -10,7 +10,7 @@ import graph.*;
* Dieser Algorithmus nummeriert alle Knoten des Graphen.
* Algorithmus: Breitensuche mit ToDo-Liste (Schlange)
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -23,7 +23,7 @@ public class GraphAlgo_Breitensuche extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -10,7 +10,7 @@ import graph.*;
* die gleiche Farbe haben und möglichst wenige Farben benutzt werden.
* Algorithmus: Backtracking
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -25,7 +25,7 @@ public class GraphAlgo_ColoringBacktracking extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}
@ -35,7 +35,7 @@ public class GraphAlgo_ColoringBacktracking extends GraphAlgo {
step();
}
private void bestimmeColoring(int benutzteFarben) {
private void bestimmeColoring(int benutzteFarben) throws InterruptedException {
int min = Integer.MAX_VALUE;
List<Knoten> knoten = g.getAlleKnoten(k->k.getFarbe()<=0);

View file

@ -9,7 +9,7 @@ import graph.*;
* die gleiche Farbe haben und möglichst wenige Farben benutzt werden.
* Algorithmus: Näherungslösung mit Greedy-Algorithmus
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
public class GraphAlgo_ColoringGreedy extends GraphAlgo {
@ -26,7 +26,7 @@ public class GraphAlgo_ColoringGreedy extends GraphAlgo {
// Ende Attribute
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
List<Knoten> knoten = g.getAlleKnoten();
info("Wiederhole für jeden Knoten");
for (Knoten aktuellerKnoten: knoten ) {

View file

@ -10,7 +10,7 @@ import graph.*;
* die gleiche Farbe haben und möglichst wenige Farben benutzt werden.
* Algorithmus: Näherungslösung mit Greedy-Algorithmus (Knotenreihenfolge zufällig)
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -28,7 +28,7 @@ public class GraphAlgo_ColoringGreedyRandom extends GraphAlgo {
// Ende Attribute
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
List<Knoten> knoten = g.getAlleKnoten();
Collections.shuffle(knoten);
info("Wiederhole für jeden Knoten");

View file

@ -10,7 +10,7 @@ import graph.*;
* Dieser Algorithmus findet die kürzesten Pfade in einem gewichteten Graphen.
* Algorithmus: Dijkstra
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -31,7 +31,7 @@ public class GraphAlgo_Dijkstra extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -11,7 +11,7 @@ import graph.*;
* Dieser Algorithmus findet die kürzesten Pfade in einem gewichteten Graphen.
* Algorithmus: Dijkstra
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -34,7 +34,7 @@ public class GraphAlgo_DijkstraMitVorgaenger extends GraphAlgo {
gp.getGraphOptions().knotenLangtext = new String[]{"Infotext","Entfernung","Vorgänger","Markiert","Besucht"};
}
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -10,7 +10,7 @@ import graph.*;
* und bestimmt den Zeitbedarf.
* Algorithmus: Backtracking
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -26,7 +26,7 @@ public class GraphAlgo_DominatingSetBacktracking extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
long starttime = System.currentTimeMillis();
if (g.getAnzahlKnoten()==0) {
return;
@ -41,7 +41,7 @@ public class GraphAlgo_DominatingSetBacktracking extends GraphAlgo {
private void bestimmeDominierendeMenge(int knoten) {
private void bestimmeDominierendeMenge(int knoten) throws InterruptedException {
List<String> status = g.getStatus();
List<Knoten> markierte = g.getAlleKnoten(kn->kn.isMarkiert());

View file

@ -11,7 +11,7 @@ import graph.*;
* Dieser Algorithmus bestimmt die kleinste dominierende Menge in einem Graphen
* und bestimmt den Zeitbedarf.
* Algorithmus: Genetischer Algorithmus
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -31,7 +31,7 @@ public class GraphAlgo_DominatingSetGenetisch extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
population = new int[popGroesse][g.getAnzahlKnoten()];
double[] bewertungen = new double[popGroesse];
for(int i=0; i<popGroesse; i++) {

View file

@ -1,56 +0,0 @@
package algorithmen;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.nio.file.*;
import java.util.Random;
import graph.*;
/**
* Dieser Algorithmus bestimmt die kleinste dominierende Menge in einem Graphen
* und bestimmt den Zeitbedarf.
* Algorithmus: Greedy mit Strategie:
* Nimm den Knoten mit den meisten Nachbarn
*
* @version 1.0 from 10.12.2020
* @author Thomas Schaller
*/
public abstract class GraphAlgo_DominatingSetGreedy extends GraphAlgo {
/** Bestimmt besten Knoten nach Strategie */
protected abstract Knoten bestimmeBesten();
// Anfang Methoden
public void fuehreAlgorithmusAus() {
if (g.getAnzahlKnoten()==0) {
return;
}
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert() && !k.isBesucht());
info("Solange es noch nicht überdeckte Knoten gibt, wiederhole...");
int nr = 1;
while(knoten.size() > 0) {
info("Bestimme "+(nr++)+". hinzuzufügenden Knoten");
infoIndentMore();
Knoten bester = bestimmeBesten();
bester.setMarkiert(true);
bester.setBesucht(false);
info("Markiere diesen Knoten ...");
List<Knoten> nachbarn = g.getNachbarknoten(bester,kn->!kn.isMarkiert() && !kn.isBesucht());
for(Knoten k : nachbarn) {
k.setBesucht(true);
}
info("... und setze alle bisher nicht überdeckten Nachbarn auf besucht");
knoten = g.getAlleKnoten(kn->!kn.isMarkiert() && !kn.isBesucht());
step();
infoIndentLess();
}// end of while
nr--;
melde("Dominierende Menge mit " + nr + " Knoten gefunden.");
}
// Ende Methoden
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* Nimm den Knoten mit den meisten Nachbarn
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -48,7 +48,7 @@ public class GraphAlgo_DominatingSetGreedyA extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -13,7 +13,7 @@ import graph.*;
* und bestimmt den Zeitbedarf.
* Algorithmus: Greedy mit Strategie:
* Nimm den Knoten mit den wenigsten Nachbarn
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -47,7 +47,7 @@ public class GraphAlgo_DominatingSetGreedyB extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* Nimm den Knoten mit den meisten Nachbarn
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -29,7 +29,7 @@ public class GraphAlgo_DominatingSetGreedyC extends GraphAlgo {
/** Bestimmt besten Knoten nach Strategie:
* Nimm den Knoten mit den meisten Nachbarn
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() {
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert());
info("Wiederhole für jeden noch nicht markierten Knoten");
@ -49,7 +49,7 @@ public class GraphAlgo_DominatingSetGreedyC extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* Nimm den Knoten mit den meisten Nachbarn
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -49,7 +49,7 @@ public class GraphAlgo_DominatingSetGreedyD extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -30,7 +30,7 @@ public class GraphAlgo_DominatingSetGreedyE extends GraphAlgo {
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() throws InterruptedException {
Random r= new Random();
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
@ -68,7 +68,7 @@ public class GraphAlgo_DominatingSetGreedyE extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -30,7 +30,7 @@ public class GraphAlgo_DominatingSetGreedyF extends GraphAlgo {
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() throws InterruptedException {
Random r= new Random();
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
@ -68,7 +68,7 @@ public class GraphAlgo_DominatingSetGreedyF extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -30,7 +30,7 @@ public class GraphAlgo_DominatingSetGreedyG extends GraphAlgo {
* ein nicht abgedeckten Knoten, der von einem beliebigen schon ausgewählten Knoten die Entfernung 3 hat
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() throws InterruptedException {
Random r= new Random();
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
@ -68,7 +68,7 @@ public class GraphAlgo_DominatingSetGreedyG extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* ein nicht abgedeckten Knoten, der von möglichst vielen schon ausgewählten Knoten die Entfernung 3 hat
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -29,7 +29,7 @@ public class GraphAlgo_DominatingSetGreedyH extends GraphAlgo {
/** Bestimmt besten Knoten nach Strategie:
* ein nicht abgedeckten Knoten, der von möglichst vielen schon ausgewählten Knoten die Entfernung 3 hat
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() throws InterruptedException {
Random r = new Random();
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
List<Knoten> nichtabgedeckte = g.getAlleKnoten(k->!k.isMarkiert() && !k.isBesucht() );
@ -71,7 +71,7 @@ public class GraphAlgo_DominatingSetGreedyH extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -14,7 +14,7 @@ import graph.*;
* Algorithmus: Greedy mit Strategie:
* ein nicht abgedeckten Knoten, der von den ausgewählten Knoten eine möglichst große Entfernung hat
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -30,7 +30,7 @@ public class GraphAlgo_DominatingSetGreedyI extends GraphAlgo {
* ein nicht abgedeckten Knoten, der von den ausgewählten Knoten eine möglichst große Entfernung hat
*/
private Knoten bestimmeBesten() {
private Knoten bestimmeBesten() throws InterruptedException {
Random r = new Random();
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
List<Knoten> nichtabgedeckte = g.getAlleKnoten(k->!k.isMarkiert() && !k.isBesucht() );
@ -84,7 +84,7 @@ public class GraphAlgo_DominatingSetGreedyI extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -8,7 +8,7 @@ import graph.*;
* Algorithmus: Zunächst wird auf geraden Grad der Knoten getestet, danach
* mit Tiefensuche der Zusammenhang des Graphen überprüft.
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -18,7 +18,7 @@ public class GraphAlgo_EulerkreisExistenz extends GraphAlgo {
return "Eulerkreis (Existenz)";
}
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -25,7 +25,7 @@ public class GraphAlgo_MST_Kruskal extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
int farbe = 1;
List<Kante> kanten = g.getAlleKanten();
List<Knoten> knoten = g.getAlleKnoten();

View file

@ -24,7 +24,7 @@ public class GraphAlgo_MST_Prim extends GraphAlgo {
return "MST (Prim)";
}
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
int markiert = 0;
List<Knoten> knoten;
List<Kante> kanten;

View file

@ -10,7 +10,7 @@ import graph.*;
* Dieser Algorithmus findet die kürzesten Pfade in einem ungewichteten Graphen.
* Algorithmus: Algorithmus A von Moore
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -23,7 +23,7 @@ public class GraphAlgo_Moore extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -32,7 +32,7 @@ public class GraphAlgo_TSPBacktracking extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
start = this.getStartKnoten();
probiere(start);
g.setStatus(besteLoesung);
@ -40,7 +40,7 @@ public class GraphAlgo_TSPBacktracking extends GraphAlgo {
melde("beste Route gefunden:" +getInfo());
} // end of for
public void probiere(Knoten akt) {
public void probiere(Knoten akt) throws InterruptedException {
boolean fertig = true;
infoIndentMore();
akt.setMarkiert(true);

View file

@ -30,7 +30,7 @@ public class GraphAlgo_TSPGenetisch extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
population = new int[popGroesse][g.getAnzahlKnoten()+1];
double[] rundreiseLaenge = new double[popGroesse];
for(int i=0; i<popGroesse; i++) {

View file

@ -28,7 +28,7 @@ public class GraphAlgo_TSPGreedy extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
Knoten start = this.getStartKnoten();
Knoten akt = start;
Kante min;

View file

@ -29,7 +29,7 @@ public class GraphAlgo_TSPGreedy2 extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
int farbe = 1;
int anzkanten = 0;
List<Kante> kanten = g.getAlleKanten();

View file

@ -27,7 +27,7 @@ public class GraphAlgo_TSPGreedyOpt extends GraphAlgo {
}
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
Knoten start = this.getStartKnoten();
Knoten akt = start;
List<Knoten> reihung = new ArrayList<Knoten>();

View file

@ -10,7 +10,7 @@ import graph.*;
* Dieser Algorithmus nummeriert alle Knoten des Graphen.
* Algorithmus: Tiefensuche mit ToDo-Liste (Stapel)
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -24,7 +24,7 @@ public class GraphAlgo_Tiefensuche extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}

View file

@ -10,7 +10,7 @@ import graph.*;
* Dieser Algorithmus nummeriert alle Knoten des Graphen.
* Algorithmus: Tiefensuche rekursiv
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -24,14 +24,14 @@ public class GraphAlgo_TiefensucheRek extends GraphAlgo {
// Anfang Methoden
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
if (g.getAnzahlKnoten()==0) {
return;
}
nummeriere(getStartKnoten(), 0);
} // end
private int nummeriere(Knoten k, int nr) {
private int nummeriere(Knoten k, int nr) throws InterruptedException {
// Abbruchbedingung
if(k.isBesucht()) {
info("Untersuche "+g.getKnoteninfo(k,false)+" => ist schon besucht");

View file

@ -10,7 +10,7 @@ import graph.*;
* Er sucht einen Zyklus im Graphen.
* Algorithmus: Backtracking
*
* @version 1.0 from 10.12.2020
* @version 7.1 from 12.02.2025
* @author Thomas Schaller
*/
@ -22,13 +22,13 @@ public class GraphAlgo_ZyklusBacktracking extends GraphAlgo {
return "Zyklensuche (Backtracking)";
}
public void fuehreAlgorithmusAus() {
public void fuehreAlgorithmusAus() throws InterruptedException {
List<String> loesung = backtracking(getStartKnoten());
if(loesung != null) g.setStatus(loesung);
step();
}
public List<String> backtracking(Knoten k){
public List<String> backtracking(Knoten k) throws InterruptedException {
List<String> loesung = null;

View file

@ -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

View file

@ -1,268 +1,268 @@
#BlueJ package file
dependency1.from=GraphAlgo_DominatingSetGreedyF
dependency1.to=GraphAlgo
dependency1.type=UsesDependency
dependency2.from=GraphAlgo_DominatingSetGreedyF
dependency2.to=GraphAlgo_Moore
dependency2.type=UsesDependency
dependency3.from=GraphAlgo_DominatingSetGreedyG
dependency3.to=GraphAlgo
dependency3.type=UsesDependency
dependency4.from=GraphAlgo_DominatingSetGreedyG
dependency4.to=GraphAlgo_Moore
dependency4.type=UsesDependency
dependency5.from=GraphAlgo_DominatingSetGreedyE
dependency5.to=GraphAlgo
dependency5.type=UsesDependency
dependency6.from=GraphAlgo_DominatingSetGreedyE
dependency6.to=GraphAlgo_Moore
dependency6.type=UsesDependency
dependency7.from=GraphAlgo_DominatingSetGreedyH
dependency7.to=GraphAlgo
dependency7.type=UsesDependency
dependency8.from=GraphAlgo_DominatingSetGreedyH
dependency8.to=GraphAlgo_Moore
dependency8.type=UsesDependency
objectbench.height=140
objectbench.width=750
package.divider.horizontal=0.6003172085646312
package.divider.vertical=0.822463768115942
package.editor.height=661
package.editor.width=1133
package.editor.x=234
package.editor.y=49
package.frame.height=928
package.frame.width=1297
package.numDependencies=8
package.numTargets=32
package.showExtends=true
package.showUses=true
readme.height=60
readme.name=@README
readme.width=49
readme.x=10
readme.y=10
target1.height=50
target1.name=GraphAlgo_ColoringGreedyRandom
target1.showInterface=false
target1.type=ClassTarget
target1.width=290
target1.x=600
target1.y=590
target10.height=50
target10.name=GraphAlgo_DominatingSetGreedyF
target10.showInterface=false
target10.type=ClassTarget
target10.width=280
target10.x=290
target10.y=420
target11.height=50
target11.name=GraphAlgo_DominatingSetGreedyG
target11.showInterface=false
target11.type=ClassTarget
target11.width=290
target11.x=290
target11.y=470
target12.height=50
target12.name=GraphAlgo_TSPGreedy
target12.showInterface=false
target12.type=ClassTarget
target12.width=230
target12.x=600
target12.y=160
target13.height=50
target13.name=GraphAlgo_DominatingSetGreedyD
target13.showInterface=false
target13.type=ClassTarget
target13.width=290
target13.x=290
target13.y=320
target14.height=50
target14.name=GraphAlgo_TSPGenetisch
target14.showInterface=false
target14.type=ClassTarget
target14.width=230
target14.x=600
target14.y=340
target15.height=50
target15.name=GraphAlgo_DominatingSetGreedyE
target15.showInterface=false
target15.type=ClassTarget
target15.width=280
target15.x=290
target15.y=370
target16.height=50
target16.name=GraphAlgo_DominatingSetGenetisch
target16.showInterface=false
target16.type=ClassTarget
target16.width=300
target16.x=290
target16.y=640
target17.height=50
target17.name=GraphAlgo_ZyklusBacktracking
target17.showInterface=false
target17.type=ClassTarget
target17.width=210
target17.x=20
target17.y=410
target18.height=50
target18.name=GraphAlgo_DominatingSetGreedyH
target18.showInterface=false
target18.type=ClassTarget
target18.width=290
target18.x=290
target18.y=520
target19.height=50
target19.name=GraphAlgo_DominatingSetGreedyI
target19.showInterface=false
target19.type=ClassTarget
target19.width=280
target19.x=290
target19.y=570
target2.height=50
target2.name=GraphAlgo_Tiefensuche
target2.showInterface=false
target2.type=ClassTarget
target2.width=210
target2.x=20
target2.y=160
target20.height=50
target20.name=GraphAlgo_Moore
target20.showInterface=false
target20.type=ClassTarget
target20.width=210
target20.x=10
target20.y=480
target21.height=50
target21.name=GraphAlgo_BellmanFord
target21.showInterface=false
target21.type=ClassTarget
target21.width=210
target21.x=10
target21.y=660
target22.height=50
target22.name=GraphAlgo_Breitensuche
target22.showInterface=false
target22.type=ClassTarget
target22.width=210
target22.x=20
target22.y=280
target23.height=50
target23.name=GraphAlgo_toplogischeSortierung
target23.showInterface=false
target23.type=ClassTarget
target23.width=210
target23.x=20
target23.y=350
target24.height=50
target24.name=GraphAlgo_DominatingSetBacktracking
target24.showInterface=false
target24.type=ClassTarget
target24.width=320
target24.x=290
target24.y=100
target25.height=50
target25.name=GraphAlgo_ColoringGreedy
target25.showInterface=false
target25.type=ClassTarget
target25.width=240
target25.x=600
target25.y=530
target26.height=50
target26.name=GraphAlgo_DijkstraMitVorgaenger
target26.showInterface=false
target26.type=ClassTarget
target26.width=210
target26.x=10
target26.y=600
target27.height=50
target27.name=GraphAlgo_EulerkreisExistenz
target27.showInterface=false
target27.type=ClassTarget
target27.width=210
target27.x=20
target27.y=100
target28.height=50
target28.name=GraphAlgo_TiefensucheRek
target28.showInterface=false
target28.type=ClassTarget
target28.width=210
target28.x=20
target28.y=220
target29.height=50
target29.name=GraphAlgo_TSPGreedy2
target29.showInterface=false
target29.type=ClassTarget
target29.width=230
target29.x=600
target29.y=220
target3.height=50
target3.name=GraphAlgo_MST_Prim
target3.showInterface=false
target3.type=ClassTarget
target3.width=230
target3.x=890
target3.y=100
target30.height=50
target30.name=GraphAlgo_ColoringBacktracking
target30.showInterface=false
target30.type=ClassTarget
target30.width=270
target30.x=600
target30.y=470
target31.height=50
target31.name=GraphAlgo_Dijkstra
target31.showInterface=false
target31.type=ClassTarget
target31.width=210
target31.x=10
target31.y=540
target32.height=50
target32.name=GraphAlgo_TSPGreedyOpt
target32.showInterface=false
target32.type=ClassTarget
target32.width=230
target32.x=600
target32.y=280
target4.height=50
target4.name=GraphAlgo_TSPBacktracking
target4.showInterface=false
target4.type=ClassTarget
target4.width=240
target4.x=600
target4.y=100
target5.height=50
target5.name=GraphAlgo_DominatingSetGreedyB
target5.showInterface=false
target5.type=ClassTarget
target5.width=290
target5.x=290
target5.y=220
target6.height=50
target6.name=GraphAlgo
target6.showInterface=false
target6.type=AbstractTarget
target6.width=100
target6.x=310
target6.y=10
target7.height=50
target7.name=GraphAlgo_DominatingSetGreedyC
target7.showInterface=false
target7.type=ClassTarget
target7.width=290
target7.x=290
target7.y=270
target8.height=50
target8.name=GraphAlgo_MST_Kruskal
target8.showInterface=false
target8.type=ClassTarget
target8.width=230
target8.x=890
target8.y=160
target9.height=50
target9.name=GraphAlgo_DominatingSetGreedyA
target9.showInterface=false
target9.type=ClassTarget
target9.width=290
target9.x=290
target9.y=170
#BlueJ package file
dependency1.from=GraphAlgo_DominatingSetGreedyF
dependency1.to=GraphAlgo
dependency1.type=UsesDependency
dependency2.from=GraphAlgo_DominatingSetGreedyF
dependency2.to=GraphAlgo_Moore
dependency2.type=UsesDependency
dependency3.from=GraphAlgo_DominatingSetGreedyG
dependency3.to=GraphAlgo
dependency3.type=UsesDependency
dependency4.from=GraphAlgo_DominatingSetGreedyG
dependency4.to=GraphAlgo_Moore
dependency4.type=UsesDependency
dependency5.from=GraphAlgo_DominatingSetGreedyE
dependency5.to=GraphAlgo
dependency5.type=UsesDependency
dependency6.from=GraphAlgo_DominatingSetGreedyE
dependency6.to=GraphAlgo_Moore
dependency6.type=UsesDependency
dependency7.from=GraphAlgo_DominatingSetGreedyH
dependency7.to=GraphAlgo
dependency7.type=UsesDependency
dependency8.from=GraphAlgo_DominatingSetGreedyH
dependency8.to=GraphAlgo_Moore
dependency8.type=UsesDependency
objectbench.height=66
objectbench.width=1428
package.divider.horizontal=0.6003172085646312
package.divider.vertical=0.9027962716378163
package.editor.height=671
package.editor.width=1292
package.editor.x=100
package.editor.y=118
package.frame.height=852
package.frame.width=1452
package.numDependencies=8
package.numTargets=32
package.showExtends=true
package.showUses=true
readme.height=60
readme.name=@README
readme.width=49
readme.x=10
readme.y=10
target1.height=50
target1.name=GraphAlgo_ColoringGreedyRandom
target1.showInterface=false
target1.type=ClassTarget
target1.width=290
target1.x=740
target1.y=590
target10.height=50
target10.name=GraphAlgo_DominatingSetGreedyF
target10.showInterface=false
target10.type=ClassTarget
target10.width=280
target10.x=430
target10.y=420
target11.height=50
target11.name=GraphAlgo_DominatingSetGreedyG
target11.showInterface=false
target11.type=ClassTarget
target11.width=290
target11.x=430
target11.y=470
target12.height=50
target12.name=GraphAlgo_TSPGreedy
target12.showInterface=false
target12.type=ClassTarget
target12.width=230
target12.x=740
target12.y=160
target13.height=50
target13.name=GraphAlgo_DominatingSetGreedyD
target13.showInterface=false
target13.type=ClassTarget
target13.width=290
target13.x=430
target13.y=320
target14.height=50
target14.name=GraphAlgo_TSPGenetisch
target14.showInterface=false
target14.type=ClassTarget
target14.width=230
target14.x=740
target14.y=340
target15.height=50
target15.name=GraphAlgo_DominatingSetGreedyE
target15.showInterface=false
target15.type=ClassTarget
target15.width=280
target15.x=430
target15.y=370
target16.height=50
target16.name=GraphAlgo_DominatingSetGenetisch
target16.showInterface=false
target16.type=ClassTarget
target16.width=300
target16.x=430
target16.y=640
target17.height=50
target17.name=GraphAlgo_ZyklusBacktracking
target17.showInterface=false
target17.type=ClassTarget
target17.width=230
target17.x=160
target17.y=410
target18.height=50
target18.name=GraphAlgo_DominatingSetGreedyH
target18.showInterface=false
target18.type=ClassTarget
target18.width=290
target18.x=430
target18.y=520
target19.height=50
target19.name=GraphAlgo_DominatingSetGreedyI
target19.showInterface=false
target19.type=ClassTarget
target19.width=280
target19.x=430
target19.y=570
target2.height=50
target2.name=GraphAlgo_Tiefensuche
target2.showInterface=false
target2.type=ClassTarget
target2.width=210
target2.x=160
target2.y=160
target20.height=50
target20.name=GraphAlgo_Moore
target20.showInterface=false
target20.type=ClassTarget
target20.width=210
target20.x=150
target20.y=480
target21.height=50
target21.name=GraphAlgo_BellmanFord
target21.showInterface=false
target21.type=ClassTarget
target21.width=210
target21.x=150
target21.y=660
target22.height=50
target22.name=GraphAlgo_Breitensuche
target22.showInterface=false
target22.type=ClassTarget
target22.width=210
target22.x=160
target22.y=280
target23.height=50
target23.name=GraphAlgo_toplogischeSortierung
target23.showInterface=false
target23.type=ClassTarget
target23.width=250
target23.x=160
target23.y=350
target24.height=50
target24.name=GraphAlgo_DominatingSetBacktracking
target24.showInterface=false
target24.type=ClassTarget
target24.width=320
target24.x=430
target24.y=100
target25.height=50
target25.name=GraphAlgo_ColoringGreedy
target25.showInterface=false
target25.type=ClassTarget
target25.width=240
target25.x=740
target25.y=530
target26.height=50
target26.name=GraphAlgo_DijkstraMitVorgaenger
target26.showInterface=false
target26.type=ClassTarget
target26.width=250
target26.x=150
target26.y=600
target27.height=50
target27.name=GraphAlgo_EulerkreisExistenz
target27.showInterface=false
target27.type=ClassTarget
target27.width=220
target27.x=160
target27.y=100
target28.height=50
target28.name=GraphAlgo_TiefensucheRek
target28.showInterface=false
target28.type=ClassTarget
target28.width=210
target28.x=160
target28.y=220
target29.height=50
target29.name=GraphAlgo_TSPGreedy2
target29.showInterface=false
target29.type=ClassTarget
target29.width=230
target29.x=740
target29.y=220
target3.height=50
target3.name=GraphAlgo_TSPBacktracking
target3.showInterface=false
target3.type=ClassTarget
target3.width=240
target3.x=740
target3.y=100
target30.height=50
target30.name=GraphAlgo_ColoringBacktracking
target30.showInterface=false
target30.type=ClassTarget
target30.width=270
target30.x=740
target30.y=470
target31.height=50
target31.name=GraphAlgo_Dijkstra
target31.showInterface=false
target31.type=ClassTarget
target31.width=210
target31.x=150
target31.y=540
target32.height=50
target32.name=GraphAlgo_TSPGreedyOpt
target32.showInterface=false
target32.type=ClassTarget
target32.width=230
target32.x=740
target32.y=280
target4.height=50
target4.name=GraphAlgo_MST_Prim
target4.showInterface=false
target4.type=ClassTarget
target4.width=230
target4.x=1030
target4.y=100
target5.height=50
target5.name=GraphAlgo_DominatingSetGreedyB
target5.showInterface=false
target5.type=ClassTarget
target5.width=290
target5.x=430
target5.y=220
target6.height=50
target6.name=GraphAlgo
target6.showInterface=false
target6.type=AbstractTarget
target6.width=100
target6.x=450
target6.y=10
target7.height=50
target7.name=GraphAlgo_DominatingSetGreedyC
target7.showInterface=false
target7.type=ClassTarget
target7.width=290
target7.x=430
target7.y=270
target8.height=50
target8.name=GraphAlgo_MST_Kruskal
target8.showInterface=false
target8.type=ClassTarget
target8.width=230
target8.x=1030
target8.y=160
target9.height=50
target9.name=GraphAlgo_DominatingSetGreedyA
target9.showInterface=false
target9.type=ClassTarget
target9.width=290
target9.x=430
target9.y=170