- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDepthFirstTraversal.java
More file actions
Latest commit
34 lines (27 loc) · 862 Bytes
/
Copy pathDepthFirstTraversal.java
File metadata and controls
34 lines (27 loc) · 862 Bytes
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
packagegraph;
importjava.util.Collections;
importjava.util.ArrayDeque;
/* See restrictions in Graph.java. */
/** Implements a depth-first traversal of a graph. Generally, the
* client will extend this class, overriding the visit and
* postVisit methods, as desired (by default, they do nothing).
* @author Rafayel Mkrtchyan
*/
publicclassDepthFirstTraversalextendsTraversal {
/** A depth-first Traversal of G, using FRINGE as the fringe. */
protectedDepthFirstTraversal(GraphG) {
super(G, Collections.asLifoQueue(newArrayDeque<Integer>()));
}
@Override
protectedbooleanvisit(intv) {
returnsuper.visit(v);
}
@Override
protectedbooleanpostVisit(intv) {
returnsuper.postVisit(v);
}
@Override
protectedbooleanshouldPostVisit(intv) {
returntrue;
}
}