1package aud.example.graph;
3import java.util.Comparator;
13 new Comparator<MyNode>() {
16 return (d<0.0) ? -1 : (d>0.0 ? +1 : 0);
48 System.out.println(
"open="+open.
toString());
52 assert(!Double.isInfinite(s.
d));
58 System.err.println(e);
66 if (Double.isInfinite(t.
d)) {
81 System.out.println(
"update "+t+
": priority "+t.
d+
" -> "+pr+
82 ", parent "+t.
p+
" -> "+s);
90 System.out.println(
"open="+open.
toString());
Priority queue based on binary min-heap.
boolean is_empty()
Is PQ empty?
void push(T x)
Add entry to PQ.
boolean contains(T x)
Is x contained in PQ?
T pop()
Pop minimal element from PQ.
void lower(T x)
update heap after lowering priority of x
edge with all possible attributes that we require ;-)
graph based on aud.graph.GraphAM
node with all possible attributes that we require ;-)
MyNode p
node from which node was reached (defines spanning tree)
double d
distance to start node (sum of weighs or edge count if no weights defined)
int ord
time when node is (first marked/put into front)
Priority first search implementation.
abstract double priority(MyNode node, MyEdge e)
Compute priority of a node:
void start(MyNode s0)
start traversal at node s0
PriorityFirstSearch(MyGraph g)
Comparator< MyNode > compareNodes
comparator for {#link aud.PriorityQueue}
interface for traversals of MyGraph
int verbose
set verbosity (extra output if >0)
void initialize()
initialize graph for traversal (reset all attributes), provided for convenience to be called by start
void showMark(MyNode node)
callback to give visual feedback on marking a node
Vector< Edge > getOutEdges(Node node)
AuD lecture: Data structures, algorithms, examples.