mirror of
https://codeberg.org/qg-info-unterricht/zpg-graphentester.git
synced 2026-03-24 20:48:26 +01:00
DM Greedy Vererbung geändert, Ausgabe der Knoten hinzugefügt. CTXT DAteien aus der VVerwaltung raus. Name fürs Hauptfenster
This commit is contained in:
parent
160bbe909a
commit
39a2f13410
68 changed files with 145 additions and 1929 deletions
|
|
@ -1,44 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo
|
||||
comment0.text=\n\n\ description\n\n\ @version\ 1.0\ from\ 26.04.2019\n\ @author\ \n
|
||||
comment1.params=
|
||||
comment1.target=GraphAlgo()
|
||||
comment10.params=delay
|
||||
comment10.target=void\ setSpeed(int)
|
||||
comment11.params=
|
||||
comment11.target=void\ run()
|
||||
comment12.params=k
|
||||
comment12.target=void\ setStartKnoten(graph.Knoten)
|
||||
comment13.params=
|
||||
comment13.target=graph.Knoten\ getStartKnoten()
|
||||
comment14.params=
|
||||
comment14.target=void\ fuehreAlgorithmusAus()
|
||||
comment15.params=
|
||||
comment15.target=java.lang.String\ getBezeichnung()
|
||||
comment16.params=s
|
||||
comment16.target=void\ melde(java.lang.String)
|
||||
comment17.params=s
|
||||
comment17.target=void\ info(java.lang.String)
|
||||
comment18.params=
|
||||
comment18.target=void\ resetInfo()
|
||||
comment19.params=
|
||||
comment19.target=void\ infoIndentMore()
|
||||
comment2.params=graphPlotter\ hilfe
|
||||
comment2.target=void\ setGUIElemente(graph.GraphPlotter,\ graph.Hilfe)
|
||||
comment20.params=
|
||||
comment20.target=void\ infoIndentLess()
|
||||
comment3.params=g
|
||||
comment3.target=void\ setGraph(graph.Graph)
|
||||
comment4.params=
|
||||
comment4.target=void\ step()
|
||||
comment5.params=
|
||||
comment5.target=boolean\ getWaitforrepaint()
|
||||
comment6.params=waitforrepaintNeu
|
||||
comment6.target=void\ setWaitforrepaint(boolean)
|
||||
comment7.params=
|
||||
comment7.target=boolean\ getWaitforclick()
|
||||
comment8.params=waitforclickNeu
|
||||
comment8.target=void\ setWaitforclick(boolean)
|
||||
comment9.params=stepping
|
||||
comment9.target=void\ setStepping(boolean)
|
||||
numComments=21
|
||||
|
|
@ -8,7 +8,8 @@ import javafx.scene.control.Alert;
|
|||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.application.Platform;
|
||||
|
||||
import javafx.scene.control.TextInputDialog;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -48,7 +49,7 @@ public abstract class GraphAlgo extends Thread {
|
|||
this.hilfe = hilfe;
|
||||
if (hilfe != null) hilfe.setGraphPlotter(gp);
|
||||
}
|
||||
|
||||
|
||||
public void setGraph(Graph g) {
|
||||
this.g = g;
|
||||
gp = null;
|
||||
|
|
@ -64,8 +65,8 @@ public abstract class GraphAlgo extends Thread {
|
|||
if (hilfe != null) hilfe.setReviewAllowed(true);
|
||||
int i = 0;
|
||||
while((waitforclick && (stepping || i*10 < speed)) && !isInterrupted()){
|
||||
Thread.sleep(10);
|
||||
i++;
|
||||
Thread.sleep(10);
|
||||
i++;
|
||||
}
|
||||
if (hilfe != null) hilfe.setReviewAllowed(false);
|
||||
g.setStatus(aktuellerZustand);
|
||||
|
|
@ -140,13 +141,27 @@ public abstract class GraphAlgo extends Thread {
|
|||
|
||||
public abstract String getBezeichnung();
|
||||
|
||||
public void eingabe() {
|
||||
Platform.runLater(() -> {
|
||||
TextInputDialog dialog = new TextInputDialog(); // create an instance
|
||||
|
||||
dialog.setTitle("Title");
|
||||
// other formatting etc
|
||||
|
||||
Optional<String> result = dialog.showAndWait();
|
||||
// this shows the dialog, waits until it is closed, and stores the result
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void melde(String s) {
|
||||
info(s);
|
||||
Platform.runLater(() -> {
|
||||
Alert meldung = new Alert(AlertType.INFORMATION, s, ButtonType.OK);
|
||||
meldung.setTitle("Information");
|
||||
meldung.setHeaderText(null);
|
||||
meldung.showAndWait();
|
||||
Alert meldung = new Alert(AlertType.INFORMATION, s, ButtonType.OK);
|
||||
meldung.setTitle("Information");
|
||||
meldung.setHeaderText(null);
|
||||
meldung.showAndWait();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -168,5 +183,4 @@ public abstract class GraphAlgo extends Thread {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_BellmanFord
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ findet\ die\ k\u00FCrzesten\ Pfade\ in\ einem\ gewichteten\ Graphen.\n\ Algorithmus\:\ Bellman-Ford\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=k
|
||||
comment2.target=java.lang.String\ knoteninfo(graph.Knoten)
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_Breitensuche
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ nummeriert\ alle\ Knoten\ des\ Graphen.\n\ Algorithmus\:\ Breitensuche\ mit\ ToDo-Liste\ (Schlange)\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_ColoringBacktracking
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ f\u00E4rbt\ einen\ Graphen,\ so\ dass\ keine\ benachbarten\ Knoten\n\ die\ gleiche\ Farbe\ haben\ und\ m\u00F6glichst\ wenige\ Farben\ benutzt\ werden.\n\ Algorithmus\:\ Backtracking\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=benutzteFarben
|
||||
comment3.target=void\ bestimmeColoring(int)
|
||||
numComments=4
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_ColoringGreedy
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ f\u00E4rbt\ einen\ Graphen,\ so\ dass\ keine\ benachbarten\ Knoten\n\ die\ gleiche\ Farbe\ haben\ und\ m\u00F6glichst\ wenige\ Farben\ benutzt\ werden.\n\ Algorithmus\:\ N\u00E4herungsl\u00F6sung\ mit\ Greedy-Algorithmus\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_ColoringGreedyRandom
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ f\u00E4rbt\ einen\ Graphen,\ so\ dass\ keine\ benachbarten\ Knoten\n\ die\ gleiche\ Farbe\ haben\ und\ m\u00F6glichst\ wenige\ Farben\ benutzt\ werden.\n\ Algorithmus\:\ N\u00E4herungsl\u00F6sung\ mit\ Greedy-Algorithmus\ (Knotenreihenfolge\ zuf\u00E4llig)\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_Dijkstra
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ findet\ die\ k\u00FCrzesten\ Pfade\ in\ einem\ gewichteten\ Graphen.\n\ Algorithmus\:\ Dijkstra\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetBacktracking
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Backtracking\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=knoten
|
||||
comment3.target=void\ bestimmeDominierendeMenge(int)
|
||||
numComments=4
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGenetisch
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Genetischer\ Algorithmus\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=
|
||||
comment3.target=int[]\ erzeugeZufaelligeTeilmenge()
|
||||
comment4.params=tm1\ tm2
|
||||
comment4.target=int[]\ kreuze(int[],\ int[])
|
||||
comment5.params=tm
|
||||
comment5.target=int[]\ mutiere(int[])
|
||||
comment6.params=tm
|
||||
comment6.target=void\ showTeilmenge(int[])
|
||||
comment7.params=tm
|
||||
comment7.target=double\ getBewertung(int[])
|
||||
numComments=8
|
||||
56
algorithmen/GraphAlgo_DominatingSetGreedy.java
Normal file
56
algorithmen/GraphAlgo_DominatingSetGreedy.java
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
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
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyA
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyA extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyA extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ public class GraphAlgo_DominatingSetGreedyA extends GraphAlgo {
|
|||
/** Bestimmt besten Knoten nach Strategie:
|
||||
* Nimm den Knoten mit den meisten Nachbarn
|
||||
*/
|
||||
private Knoten bestimmeBesten() {
|
||||
public Knoten bestimmeBesten() {
|
||||
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert());
|
||||
|
||||
info("Wiederhole für jeden noch nicht markierten Knoten");
|
||||
|
|
@ -47,32 +47,5 @@ public class GraphAlgo_DominatingSetGreedyA extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyB
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ wenigsten\ Nachbarn\ \n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ wenigsten\ Nachbarn\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -17,7 +17,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyB extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyB extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ public class GraphAlgo_DominatingSetGreedyB extends GraphAlgo {
|
|||
/** Bestimmt besten Knoten nach Strategie:
|
||||
* Nimm den Knoten mit den wenigsten Nachbarn
|
||||
*/
|
||||
private Knoten bestimmeBesten() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert());
|
||||
|
||||
info("Wiederhole für jeden noch nicht markierten Knoten");
|
||||
|
|
@ -46,32 +46,4 @@ public class GraphAlgo_DominatingSetGreedyB extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyC
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyC extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyC extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert());
|
||||
|
||||
info("Wiederhole für jeden noch nicht markierten Knoten");
|
||||
|
|
@ -48,32 +48,5 @@ public class GraphAlgo_DominatingSetGreedyC extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyD
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ Nimm\ den\ Knoten\ mit\ den\ meisten\ \ Nachbarn\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyD extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyD extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ public class GraphAlgo_DominatingSetGreedyD extends GraphAlgo {
|
|||
/** Bestimmt besten Knoten nach Strategie:
|
||||
* Nimm den Knoten mit den meisten Nachbarn
|
||||
*/
|
||||
private Knoten bestimmeBesten() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
List<Knoten> knoten = g.getAlleKnoten(k->!k.isMarkiert());
|
||||
|
||||
info("Wiederhole für jeden noch nicht markierten Knoten");
|
||||
|
|
@ -48,32 +48,4 @@ public class GraphAlgo_DominatingSetGreedyD extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyE
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyE extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyE extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
Random r= new Random();
|
||||
|
||||
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
|
||||
|
|
@ -67,32 +67,5 @@ public class GraphAlgo_DominatingSetGreedyE extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyF
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyF extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyF extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
Random r= new Random();
|
||||
|
||||
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
|
||||
|
|
@ -67,32 +67,4 @@ public class GraphAlgo_DominatingSetGreedyF extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyG
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ einem\ beliebigen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyG extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyG extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
Random r= new Random();
|
||||
|
||||
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
|
||||
|
|
@ -67,32 +67,4 @@ public class GraphAlgo_DominatingSetGreedyG extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyH
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ m\u00F6glichst\ vielen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ m\u00F6glichst\ vielen\ schon\ ausgew\u00E4hlten\ Knoten\ die\ Entfernung\ 3\ hat\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyH extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyH extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
Random r = new Random();
|
||||
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
|
||||
List<Knoten> nichtabgedeckte = g.getAlleKnoten(k->!k.isMarkiert() && !k.isBesucht() );
|
||||
|
|
@ -70,32 +70,4 @@ public class GraphAlgo_DominatingSetGreedyH extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_DominatingSetGreedyI
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ bestimmt\ die\ kleinste\ dominierende\ Menge\ in\ einem\ Graphen\n\ und\ bestimmt\ den\ Zeitbedarf.\n\ Algorithmus\:\ Greedy\ mit\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ den\ ausgew\u00E4hlten\ Knoten\ eine\ m\u00F6glichst\ gro\u00DFe\ Entfernung\ hat\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=graph.Knoten\ bestimmeBesten()
|
||||
comment2.text=\ Bestimmt\ besten\ Knoten\ nach\ Strategie\:\n\ \ ein\ nicht\ abgedeckten\ Knoten,\ der\ von\ den\ ausgew\u00E4hlten\ Knoten\ eine\ m\u00F6glichst\ gro\u00DFe\ Entfernung\ hat\n
|
||||
comment3.params=
|
||||
comment3.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=4
|
||||
|
|
@ -18,7 +18,7 @@ import graph.*;
|
|||
* @author Thomas Schaller
|
||||
*/
|
||||
|
||||
public class GraphAlgo_DominatingSetGreedyI extends GraphAlgo {
|
||||
public class GraphAlgo_DominatingSetGreedyI extends GraphAlgo_DominatingSetGreedy {
|
||||
|
||||
// Anfang Attribute
|
||||
|
||||
|
|
@ -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() {
|
||||
protected Knoten bestimmeBesten() {
|
||||
Random r = new Random();
|
||||
List<Knoten> markierte = g.getAlleKnoten(k->k.isMarkiert() );
|
||||
List<Knoten> nichtabgedeckte = g.getAlleKnoten(k->!k.isMarkiert() && !k.isBesucht() );
|
||||
|
|
@ -82,33 +82,4 @@ public class GraphAlgo_DominatingSetGreedyI extends GraphAlgo {
|
|||
return bester;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
}
|
||||
|
||||
// Ende Methoden
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_EulerkreisExistenz
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ testet,\ ob\ ein\ Eulerkreis\ existiert.\n\ Algorithmus\:\ Zun\u00E4chst\ wird\ auf\ geraden\ Grad\ der\ Knoten\ getestet,\ danach\ \n\ mit\ Tiefensuche\ der\ Zusammenhang\ des\ Graphen\ \u00FCberpr\u00FCft.\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_MST_Kruskal
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ minimal\ Spanning\ Tree\n\ Algorithmus\:\ Kruskal\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_MST_Prim
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ minimal\ Spanning\ Tree\n\ Algorithmus\:\ Prim\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_Moore
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ findet\ die\ k\u00FCrzesten\ Pfade\ in\ einem\ ungewichteten\ Graphen.\n\ Algorithmus\:\ Algorithmus\ A\ von\ Moore\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TSPBacktracking
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ m\u00F6glichst\ kurzen\ Hamilton-Kreis\ (Traveling\n\ Salesman\ Problem).\n\ Algorithmus\:\ Backtracking\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=akt
|
||||
comment3.target=void\ probiere(graph.Knoten)
|
||||
comment4.params=
|
||||
comment4.target=java.lang.String\ getInfo()
|
||||
numComments=5
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TSPGenetisch
|
||||
comment0.text=\n\n\ description\n\n\ @version\ 1.0\ from\ 26.04.2019\n\ @author\ \n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=
|
||||
comment3.target=int[]\ erzeugeZufaelligeRundreise()
|
||||
comment4.params=rr1\ rr2
|
||||
comment4.target=int[]\ kreuze(int[],\ int[])
|
||||
comment5.params=rr
|
||||
comment5.target=int[]\ mutiere(int[])
|
||||
comment6.params=rr
|
||||
comment6.target=int[]\ mutiere2(int[])
|
||||
comment7.params=rundreise
|
||||
comment7.target=void\ showRundreise(int[])
|
||||
comment8.params=rundreise
|
||||
comment8.target=double\ getLaenge(int[])
|
||||
comment9.params=
|
||||
comment9.target=java.lang.String\ getInfo()
|
||||
numComments=10
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TSPGreedy
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ m\u00F6glichst\ kurzen\ Hamilton-Kreis\ (Traveling\n\ Salesman\ Problem).\n\ Algorithmus\:\ Greedy\n\ Strategie\:\ Verl\u00E4ngere\ den\ Weg\ immer\ mit\ der\ k\u00FCrzesten\ Kante,\ die\ vom\ aktuellen\ Ende\ der\ Route\ ausgeht.\n\ vlg.\ Minimal\ Spanning\ Tree\ (Prim)\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=
|
||||
comment3.target=java.lang.String\ getInfo()
|
||||
numComments=4
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TSPGreedy2
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ m\u00F6glichst\ kurzen\ Hamilton-Kreis\ (Traveling\n\ Salesman\ Problem).\n\ Algorithmus\:\ Greedy\n\ Strategie\:\ Sortiere\ Kanten\ der\ L\u00E4nge\ nach.\ F\u00FCge\ sie\ der\ Reihe\ nach\ der\ Route\ hinzu,\ wenn\ nicht\ schon\ ein\n\ Weg\ zwischen\ den\ beiden\ Knoten\ vorhanden\ ist\ und\ die\ Knoten\ nicht\ schon\ Grad\ zwei\ erreicht\ haben.\n\ vgl.\ Minimal\ Spanning\ Tree\ (Kruskal)\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=k
|
||||
comment3.target=boolean\ istRoutenende(graph.Knoten)
|
||||
comment4.params=k
|
||||
comment4.target=int\ bestimmeGrad(graph.Knoten)
|
||||
comment5.params=
|
||||
comment5.target=java.lang.String\ getInfo()
|
||||
numComments=6
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TSPGreedyOpt
|
||||
comment0.text=\n\n\ Dieser\ Algorithmus\ sucht\ einen\ m\u00F6glichst\ kurzen\ Hamilton-Kreis\ (Traveling\n\ Salesman\ Problem).\n\ Algorithmus\:\ Greedy\ mit\ anschlie\u00DFender\ Optimierung\:\ \n\ Jeder\ Knoten\ wird\ der\ Reihe\ nach\ aus\ der\ Rundreise\ entfernt\ und\ dort\ wieder\ eingef\u00FCgt,\ wo\ die\ Rundreise\n\ sich\ am\ wenigsten\ verl\u00E4ngert.\ Diese\ Optimierung\ wird\ 5x\ wiederholt.\n\n\ @version\ 1.0\ from\ 11.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=
|
||||
comment3.target=double\ getLaenge()
|
||||
comment4.params=
|
||||
comment4.target=java.lang.String\ getInfo()
|
||||
numComments=5
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_Tiefensuche
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ nummeriert\ alle\ Knoten\ des\ Graphen.\n\ Algorithmus\:\ Tiefensuche\ mit\ ToDo-Liste\ (Stapel)\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_TiefensucheRek
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ nummeriert\ alle\ Knoten\ des\ Graphen.\n\ Algorithmus\:\ Tiefensuche\ rekursiv\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=k\ nr
|
||||
comment3.target=int\ nummeriere(graph.Knoten,\ int)
|
||||
numComments=4
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_ZyklusBacktracking
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ ist\ ein\ Beispiel\ f\u00FCr\ einen\ Backtracking-Algorithmus.\n\ Er\ sucht\ einen\ Zyklus\ im\ Graphen.\n\ Algorithmus\:\ Backtracking\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
comment3.params=k
|
||||
comment3.target=java.util.List\ backtracking(graph.Knoten)
|
||||
numComments=4
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
#BlueJ class context
|
||||
comment0.target=GraphAlgo_toplogischeSortierung
|
||||
comment0.text=\n\ Dieser\ Algorithmus\ findet\ eine\ topologische\ Sortierung\ des\ Graphen.\n\n\ @version\ 1.0\ from\ 10.12.2020\n\ @author\ Thomas\ Schaller\n
|
||||
comment1.params=
|
||||
comment1.target=java.lang.String\ getBezeichnung()
|
||||
comment2.params=
|
||||
comment2.target=void\ fuehreAlgorithmusAus()
|
||||
numComments=3
|
||||
|
|
@ -23,16 +23,16 @@ dependency7.type=UsesDependency
|
|||
dependency8.from=GraphAlgo_DominatingSetGreedyH
|
||||
dependency8.to=GraphAlgo_Moore
|
||||
dependency8.type=UsesDependency
|
||||
objectbench.height=135
|
||||
objectbench.width=1273
|
||||
objectbench.height=157
|
||||
objectbench.width=1896
|
||||
package.divider.horizontal=0.6003172085646312
|
||||
package.divider.vertical=0.8287092882991556
|
||||
package.editor.height=666
|
||||
package.editor.width=1142
|
||||
package.editor.x=533
|
||||
package.editor.y=122
|
||||
package.frame.height=928
|
||||
package.frame.width=1297
|
||||
package.divider.vertical=0.829698857736241
|
||||
package.editor.height=792
|
||||
package.editor.width=1774
|
||||
package.editor.x=1919
|
||||
package.editor.y=0
|
||||
package.frame.height=1054
|
||||
package.frame.width=1922
|
||||
package.numDependencies=8
|
||||
package.numTargets=31
|
||||
package.showExtends=true
|
||||
|
|
@ -46,35 +46,35 @@ target1.height=50
|
|||
target1.name=GraphAlgo_ColoringGreedyRandom
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=250
|
||||
target1.width=260
|
||||
target1.x=600
|
||||
target1.y=590
|
||||
target10.height=50
|
||||
target10.name=GraphAlgo_DominatingSetGreedyF
|
||||
target10.showInterface=false
|
||||
target10.type=ClassTarget
|
||||
target10.width=250
|
||||
target10.width=260
|
||||
target10.x=290
|
||||
target10.y=420
|
||||
target11.height=50
|
||||
target11.name=GraphAlgo_TSPGreedy
|
||||
target11.name=GraphAlgo_DominatingSetGreedyG
|
||||
target11.showInterface=false
|
||||
target11.type=ClassTarget
|
||||
target11.width=230
|
||||
target11.x=600
|
||||
target11.y=160
|
||||
target11.width=260
|
||||
target11.x=290
|
||||
target11.y=470
|
||||
target12.height=50
|
||||
target12.name=GraphAlgo_DominatingSetGreedyG
|
||||
target12.name=GraphAlgo_TSPGreedy
|
||||
target12.showInterface=false
|
||||
target12.type=ClassTarget
|
||||
target12.width=250
|
||||
target12.x=290
|
||||
target12.y=470
|
||||
target12.width=230
|
||||
target12.x=600
|
||||
target12.y=160
|
||||
target13.height=50
|
||||
target13.name=GraphAlgo_DominatingSetGreedyD
|
||||
target13.showInterface=false
|
||||
target13.type=ClassTarget
|
||||
target13.width=250
|
||||
target13.width=260
|
||||
target13.x=290
|
||||
target13.y=320
|
||||
target14.height=50
|
||||
|
|
@ -88,14 +88,14 @@ target15.height=50
|
|||
target15.name=GraphAlgo_DominatingSetGreedyE
|
||||
target15.showInterface=false
|
||||
target15.type=ClassTarget
|
||||
target15.width=250
|
||||
target15.width=260
|
||||
target15.x=290
|
||||
target15.y=370
|
||||
target16.height=50
|
||||
target16.name=GraphAlgo_DominatingSetGenetisch
|
||||
target16.showInterface=false
|
||||
target16.type=ClassTarget
|
||||
target16.width=260
|
||||
target16.width=270
|
||||
target16.x=290
|
||||
target16.y=640
|
||||
target17.height=50
|
||||
|
|
@ -109,14 +109,14 @@ target18.height=50
|
|||
target18.name=GraphAlgo_DominatingSetGreedyH
|
||||
target18.showInterface=false
|
||||
target18.type=ClassTarget
|
||||
target18.width=250
|
||||
target18.width=260
|
||||
target18.x=290
|
||||
target18.y=520
|
||||
target19.height=50
|
||||
target19.name=GraphAlgo_DominatingSetGreedyI
|
||||
target19.showInterface=false
|
||||
target19.type=ClassTarget
|
||||
target19.width=240
|
||||
target19.width=250
|
||||
target19.x=290
|
||||
target19.y=570
|
||||
target2.height=50
|
||||
|
|
@ -151,14 +151,14 @@ target23.height=50
|
|||
target23.name=GraphAlgo_toplogischeSortierung
|
||||
target23.showInterface=false
|
||||
target23.type=ClassTarget
|
||||
target23.width=240
|
||||
target23.width=250
|
||||
target23.x=20
|
||||
target23.y=370
|
||||
target24.height=50
|
||||
target24.name=GraphAlgo_DominatingSetBacktracking
|
||||
target24.showInterface=false
|
||||
target24.type=ClassTarget
|
||||
target24.width=280
|
||||
target24.width=290
|
||||
target24.x=290
|
||||
target24.y=100
|
||||
target25.height=50
|
||||
|
|
@ -193,15 +193,15 @@ target29.height=50
|
|||
target29.name=GraphAlgo_ColoringBacktracking
|
||||
target29.showInterface=false
|
||||
target29.type=ClassTarget
|
||||
target29.width=240
|
||||
target29.width=250
|
||||
target29.x=600
|
||||
target29.y=470
|
||||
target3.height=50
|
||||
target3.name=GraphAlgo_TSPBacktracking
|
||||
target3.name=GraphAlgo_MST_Prim
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=230
|
||||
target3.x=600
|
||||
target3.x=890
|
||||
target3.y=100
|
||||
target30.height=50
|
||||
target30.name=GraphAlgo_Dijkstra
|
||||
|
|
@ -218,33 +218,33 @@ target31.width=230
|
|||
target31.x=600
|
||||
target31.y=280
|
||||
target4.height=50
|
||||
target4.name=GraphAlgo_MST_Prim
|
||||
target4.name=GraphAlgo_TSPBacktracking
|
||||
target4.showInterface=false
|
||||
target4.type=ClassTarget
|
||||
target4.width=230
|
||||
target4.x=890
|
||||
target4.x=600
|
||||
target4.y=100
|
||||
target5.height=50
|
||||
target5.name=GraphAlgo_DominatingSetGreedyB
|
||||
target5.showInterface=false
|
||||
target5.type=ClassTarget
|
||||
target5.width=250
|
||||
target5.width=260
|
||||
target5.x=290
|
||||
target5.y=220
|
||||
target6.height=50
|
||||
target6.name=GraphAlgo_DominatingSetGreedyC
|
||||
target6.name=GraphAlgo
|
||||
target6.showInterface=false
|
||||
target6.type=ClassTarget
|
||||
target6.width=250
|
||||
target6.x=290
|
||||
target6.y=270
|
||||
target6.type=AbstractTarget
|
||||
target6.width=90
|
||||
target6.x=310
|
||||
target6.y=10
|
||||
target7.height=50
|
||||
target7.name=GraphAlgo
|
||||
target7.name=GraphAlgo_DominatingSetGreedyC
|
||||
target7.showInterface=false
|
||||
target7.type=AbstractTarget
|
||||
target7.width=90
|
||||
target7.x=310
|
||||
target7.y=10
|
||||
target7.type=ClassTarget
|
||||
target7.width=260
|
||||
target7.x=290
|
||||
target7.y=270
|
||||
target8.height=50
|
||||
target8.name=GraphAlgo_MST_Kruskal
|
||||
target8.showInterface=false
|
||||
|
|
@ -256,6 +256,6 @@ target9.height=50
|
|||
target9.name=GraphAlgo_DominatingSetGreedyA
|
||||
target9.showInterface=false
|
||||
target9.type=ClassTarget
|
||||
target9.width=250
|
||||
target9.width=260
|
||||
target9.x=290
|
||||
target9.y=170
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue