Repository navigation
Expand file tree
/
Copy pathThreeTenAlg.java
More file actions
81 lines (69 loc) · 1.74 KB
/
Copy pathThreeTenAlg.java
File metadata and controls
81 lines (69 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.util.EdgeType;
import javax.swing.JPanel;
/**
* Interface for graph algorithms in the simulator.
*
* @author Katherine (Raven) Russell
*/
interface ThreeTenAlg {
/**
* Indicates the edge type required by the algotithm.
*
* @return the edge type expected by the algorithm
*/
public EdgeType graphEdgeType();
/**
* Indicates if the algorithm has been started.
*
* @return true if the algorithm has been started
*/
public boolean isStarted();
/**
* What to do before the simulator begins.
*/
public void start();
/**
* What to do after a step to "clean up".
*/
public void cleanUpLastStep();
/**
* What to do before a step to "get started".
*
* @return true if there was another step setup
*/
public boolean setupNextStep();
/**
* What to actually do during a step.
*
*/
public void doNextStep();
/**
* What to do when the simulator is stepped.
*
* @return whether or not there are more steps.
*/
public default boolean step() {
if(!isStarted()) {
start();
return true;
}
cleanUpLastStep();
if(!setupNextStep()) {
finish();
return false;
}
doNextStep();
return true;
}
/**
* What to do after the simulator finishes all steps.
*/
public void finish();
/**
* Resets the algorithm for a new graph.
*
* @param graph the new graph
*/
public void reset(Graph<GraphNode, GraphEdge> graph);
}