Rename Instance -> Data.
This commit is contained in:
parent
960d1b1845
commit
3a17f55571
13 changed files with 58 additions and 58 deletions
|
@ -6,15 +6,15 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public abstract class AbstractAlgorithm<Observer> {
|
public abstract class AbstractAlgorithm<Observer> {
|
||||||
|
|
||||||
protected AbstractInstance instance;
|
protected AbstractData instance;
|
||||||
protected ArrayList<Observer> observers;
|
protected ArrayList<Observer> observers;
|
||||||
|
|
||||||
protected AbstractAlgorithm(AbstractInstance instance) {
|
protected AbstractAlgorithm(AbstractData instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.observers = new ArrayList<Observer>();
|
this.observers = new ArrayList<Observer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractAlgorithm(AbstractInstance instance, ArrayList<Observer> observers) {
|
protected AbstractAlgorithm(AbstractData instance, ArrayList<Observer> observers) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.observers = observers;;
|
this.observers = observers;;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public abstract class AbstractAlgorithm<Observer> {
|
||||||
/**
|
/**
|
||||||
* @return Instance corresponding to this algorithm.
|
* @return Instance corresponding to this algorithm.
|
||||||
*/
|
*/
|
||||||
public AbstractInstance getInstance() { return instance; }
|
public AbstractData getInstance() { return instance; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the algorithm and update the current solution.
|
* Run the algorithm and update the current solution.
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.insa.algo;
|
||||||
|
|
||||||
import org.insa.graph.Graph;
|
import org.insa.graph.Graph;
|
||||||
|
|
||||||
public abstract class AbstractInstance {
|
public abstract class AbstractData {
|
||||||
|
|
||||||
protected Graph graph;
|
protected Graph graph;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ public abstract class AbstractInstance {
|
||||||
*
|
*
|
||||||
* @param graph
|
* @param graph
|
||||||
*/
|
*/
|
||||||
protected AbstractInstance(Graph graph) {
|
protected AbstractData(Graph graph) {
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,20 +22,20 @@ public abstract class AbstractSolution {
|
||||||
Duration solvingTime;
|
Duration solvingTime;
|
||||||
|
|
||||||
// Original instance of the solution
|
// Original instance of the solution
|
||||||
AbstractInstance instance;
|
AbstractData instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new abstract solution with unknown status.
|
* Create a new abstract solution with unknown status.
|
||||||
*
|
*
|
||||||
* @param instance
|
* @param instance
|
||||||
*/
|
*/
|
||||||
protected AbstractSolution(AbstractInstance instance) {
|
protected AbstractSolution(AbstractData instance) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.solvingTime = Duration.ZERO;
|
this.solvingTime = Duration.ZERO;
|
||||||
this.status = Status.UNKNOWN;
|
this.status = Status.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AbstractSolution(AbstractInstance instance, Status status) {
|
protected AbstractSolution(AbstractData instance, Status status) {
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public abstract class AbstractSolution {
|
||||||
/**
|
/**
|
||||||
* @return Original instance for this solution.
|
* @return Original instance for this solution.
|
||||||
*/
|
*/
|
||||||
public AbstractInstance getInstance() { return instance; }
|
public AbstractData getInstance() { return instance; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Status of this solution.
|
* @return Status of this solution.
|
||||||
|
|
|
@ -9,7 +9,7 @@ public abstract class StronglyConnectedComponentsAlgorithm extends AbstractAlgor
|
||||||
* @param instance
|
* @param instance
|
||||||
* @param logOutput
|
* @param logOutput
|
||||||
*/
|
*/
|
||||||
public StronglyConnectedComponentsAlgorithm(StronglyConnectedComponentsInstance instance) {
|
public StronglyConnectedComponentsAlgorithm(StronglyConnectedComponentsData instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ public abstract class StronglyConnectedComponentsAlgorithm extends AbstractAlgor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StronglyConnectedComponentsInstance getInstance() {
|
public StronglyConnectedComponentsData getInstance() {
|
||||||
return (StronglyConnectedComponentsInstance)super.getInstance();
|
return (StronglyConnectedComponentsData)super.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.insa.algo.strongconnectivity;
|
||||||
|
|
||||||
|
import org.insa.algo.AbstractData;
|
||||||
|
import org.insa.graph.Graph;
|
||||||
|
|
||||||
|
public class StronglyConnectedComponentsData extends AbstractData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param graph
|
||||||
|
*/
|
||||||
|
public StronglyConnectedComponentsData(Graph graph) {
|
||||||
|
super(graph);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package org.insa.algo.strongconnectivity;
|
|
||||||
|
|
||||||
import org.insa.algo.AbstractInstance;
|
|
||||||
import org.insa.graph.Graph;
|
|
||||||
|
|
||||||
public class StronglyConnectedComponentsInstance extends AbstractInstance {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param graph
|
|
||||||
*/
|
|
||||||
public StronglyConnectedComponentsInstance(Graph graph) {
|
|
||||||
super(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -10,11 +10,11 @@ public class StronglyConnectedComponentsSolution extends AbstractSolution {
|
||||||
// Components
|
// Components
|
||||||
private ArrayList<ArrayList<Node>> components;
|
private ArrayList<ArrayList<Node>> components;
|
||||||
|
|
||||||
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsInstance instance) {
|
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsData instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsInstance instance,
|
protected StronglyConnectedComponentsSolution(StronglyConnectedComponentsData instance,
|
||||||
Status status, ArrayList<ArrayList<Node>> components) {
|
Status status, ArrayList<ArrayList<Node>> components) {
|
||||||
super(instance, status);
|
super(instance, status);
|
||||||
this.components = components;
|
this.components = components;
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TarjanAlgorithm extends StronglyConnectedComponentsAlgorithm {
|
||||||
// Array of strongly connected components
|
// Array of strongly connected components
|
||||||
ArrayList<ArrayList<Node>> components;
|
ArrayList<ArrayList<Node>> components;
|
||||||
|
|
||||||
public TarjanAlgorithm(StronglyConnectedComponentsInstance instance) {
|
public TarjanAlgorithm(StronglyConnectedComponentsData instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class WeaklyConnectedComponentsAlgorithm extends AbstractAlgorithm<Weakly
|
||||||
* @param instance
|
* @param instance
|
||||||
* @param logOutput
|
* @param logOutput
|
||||||
*/
|
*/
|
||||||
public WeaklyConnectedComponentsAlgorithm(WeaklyConnectedComponentsInstance instance) {
|
public WeaklyConnectedComponentsAlgorithm(WeaklyConnectedComponentsData instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ public class WeaklyConnectedComponentsAlgorithm extends AbstractAlgorithm<Weakly
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WeaklyConnectedComponentsInstance getInstance() {
|
public WeaklyConnectedComponentsData getInstance() {
|
||||||
return (WeaklyConnectedComponentsInstance)super.getInstance();
|
return (WeaklyConnectedComponentsData)super.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.insa.algo.weakconnectivity;
|
||||||
|
|
||||||
|
import org.insa.algo.AbstractData;
|
||||||
|
import org.insa.graph.Graph;
|
||||||
|
|
||||||
|
public class WeaklyConnectedComponentsData extends AbstractData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param graph
|
||||||
|
*/
|
||||||
|
public WeaklyConnectedComponentsData(Graph graph) {
|
||||||
|
super(graph);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package org.insa.algo.weakconnectivity;
|
|
||||||
|
|
||||||
import org.insa.algo.AbstractInstance;
|
|
||||||
import org.insa.graph.Graph;
|
|
||||||
|
|
||||||
public class WeaklyConnectedComponentsInstance extends AbstractInstance {
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param graph
|
|
||||||
*/
|
|
||||||
public WeaklyConnectedComponentsInstance(Graph graph) {
|
|
||||||
super(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -10,11 +10,11 @@ public class WeaklyConnectedComponentsSolution extends AbstractSolution {
|
||||||
// Components
|
// Components
|
||||||
private ArrayList<ArrayList<Node>> components;
|
private ArrayList<ArrayList<Node>> components;
|
||||||
|
|
||||||
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsInstance instance) {
|
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData instance) {
|
||||||
super(instance);
|
super(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsInstance instance,
|
protected WeaklyConnectedComponentsSolution(WeaklyConnectedComponentsData instance,
|
||||||
Status status, ArrayList<ArrayList<Node>> components) {
|
Status status, ArrayList<ArrayList<Node>> components) {
|
||||||
super(instance, status);
|
super(instance, status);
|
||||||
this.components = components;
|
this.components = components;
|
||||||
|
|
|
@ -41,12 +41,12 @@ import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import org.insa.algo.shortestpath.BellmanFordAlgorithm;
|
import org.insa.algo.shortestpath.BellmanFordAlgorithm;
|
||||||
import org.insa.algo.shortestpath.ShortestPathAlgorithm;
|
import org.insa.algo.shortestpath.ShortestPathAlgorithm;
|
||||||
import org.insa.algo.shortestpath.ShortestPathGraphicObserver;
|
import org.insa.algo.shortestpath.ShortestPathGraphicObserver;
|
||||||
import org.insa.algo.shortestpath.ShortestPathInstance;
|
import org.insa.algo.shortestpath.ShortestPathData;
|
||||||
import org.insa.algo.shortestpath.ShortestPathInstance.Mode;
|
import org.insa.algo.shortestpath.ShortestPathData.Mode;
|
||||||
import org.insa.algo.shortestpath.ShortestPathSolution;
|
import org.insa.algo.shortestpath.ShortestPathSolution;
|
||||||
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentGraphicObserver;
|
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentGraphicObserver;
|
||||||
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsAlgorithm;
|
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsAlgorithm;
|
||||||
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsInstance;
|
import org.insa.algo.weakconnectivity.WeaklyConnectedComponentsData;
|
||||||
import org.insa.drawing.Drawing;
|
import org.insa.drawing.Drawing;
|
||||||
import org.insa.drawing.graph.BlackAndWhiteGraphPalette;
|
import org.insa.drawing.graph.BlackAndWhiteGraphPalette;
|
||||||
import org.insa.drawing.graph.GraphDrawing;
|
import org.insa.drawing.graph.GraphDrawing;
|
||||||
|
@ -456,7 +456,7 @@ public class MainWindow extends JFrame {
|
||||||
wccItem.addActionListener(new ActionListener() {
|
wccItem.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
WeaklyConnectedComponentsInstance instance = new WeaklyConnectedComponentsInstance(graph);
|
WeaklyConnectedComponentsData instance = new WeaklyConnectedComponentsData(graph);
|
||||||
WeaklyConnectedComponentsAlgorithm algo = new WeaklyConnectedComponentsAlgorithm(instance);
|
WeaklyConnectedComponentsAlgorithm algo = new WeaklyConnectedComponentsAlgorithm(instance);
|
||||||
algo.addObserver(new WeaklyConnectedComponentGraphicObserver(drawing));
|
algo.addObserver(new WeaklyConnectedComponentGraphicObserver(drawing));
|
||||||
// algo.addObserver(new WeaklyConnectedComponentTextObserver(printStream));
|
// algo.addObserver(new WeaklyConnectedComponentTextObserver(printStream));
|
||||||
|
@ -485,7 +485,7 @@ public class MainWindow extends JFrame {
|
||||||
@Override
|
@Override
|
||||||
public void call(ArrayList<Node> nodes) {
|
public void call(ArrayList<Node> nodes) {
|
||||||
launchShortestPathThread(new BellmanFordAlgorithm(
|
launchShortestPathThread(new BellmanFordAlgorithm(
|
||||||
new ShortestPathInstance(graph, nodes.get(0), nodes.get(1), mode)));
|
new ShortestPathData(graph, nodes.get(0), nodes.get(1), mode)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue