AuD
Lecture 'Algorithmen und Datenstrukturen' (code examples)
Traversal.java
Go to the documentation of this file.
1package aud.example.graph;
2
3import aud.util.*;
4
6public abstract class Traversal {
7 protected MyGraph g_ = null;
8 protected int time_ = 0;
9
13 public int nsteps = 1;
15 public int verbose = 0;
16
18 public Traversal(MyGraph g) {
19 g_=g;
20 }
21
23 MyGraph graph() { return g_; }
24
26 public abstract String name();
27
29 public abstract void start(MyNode s0);
30
34 protected void initialize() {
35 for (MyNode node : g_) {
36 node.ord=-1;
37 node.p=null;
38 node.d=Double.POSITIVE_INFINITY;
39 node.f=Double.POSITIVE_INFINITY;
40 }
41 }
42
44 public void showMark(MyNode node) {
45 node.color="lightblue";
46 }
47
49 void showVisit(MyNode node) {
50 ((SimpleDecorator) g_.getDecorator()).markNode(node);
51 ((SimpleDecorator) g_.getDecorator()).highlightNode(node);
52 if (node.p!=null) {
53 MyEdge e=g_.getEdge(node.p,node);
54 ((SimpleDecorator) g_.getDecorator()).markEdge(e);
55 ((SimpleDecorator) g_.getDecorator()).highlightEdge(e);
56 }
57 if (time_++%nsteps==0 && singlestepper!=null)
58 singlestepper.halt("visit "+node.toString());
59 }
60}
edge with all possible attributes that we require ;-)
Definition: MyEdge.java:6
graph based on aud.graph.GraphAM
Definition: MyGraph.java:11
GraphvizDecorator getDecorator()
Definition: MyGraph.java:34
node with all possible attributes that we require ;-)
Definition: MyNode.java:6
MyNode p
node from which node was reached (defines spanning tree)
Definition: MyNode.java:16
String color
color as string
Definition: MyNode.java:27
interface for traversals of MyGraph
Definition: Traversal.java:6
Traversal(MyGraph g)
initiate traversal of g
Definition: Traversal.java:18
abstract String name()
get traversal name
SingleStepper singlestepper
may halt if single stepper was set
Definition: Traversal.java:11
int verbose
set verbosity (extra output if >0)
Definition: Traversal.java:15
int nsteps
halt every nsteps steps in time_
Definition: Traversal.java:13
void initialize()
initialize graph for traversal (reset all attributes), provided for convenience to be called by start
Definition: Traversal.java:34
void showMark(MyNode node)
callback to give visual feedback on marking a node
Definition: Traversal.java:44
abstract void start(MyNode s0)
start traversal at node s0
Edge getEdge(Node source, Node destination)
Definition: GraphAM.java:80
Example for a simple decorator.
Simple framework for single stepping code.
void halt(String text, int timeout)
display text and wait for user or timeout
utilities (not related to AuD lecture)
Definition: Colormap.java:1
AuD lecture: Data structures, algorithms, examples.
Definition: A234Tree.java:1