-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexInterface.java
More file actions
89 lines (72 loc) · 3.02 KB
/
VertexInterface.java
File metadata and controls
89 lines (72 loc) · 3.02 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
82
83
84
85
86
87
88
89
import java.util.Iterator;
/** An interface for a vertex in a graph. */
public interface VertexInterface<T> {
/** Gets this vertex's label.
* @return The object that labels the vertex.
*/
public T getLabel();
/** Marks this vertex as visited. */
public void visit();
/** Removes this vertex's visited mark. */
public void unvisit();
/** Sees whether the vertex is marked as visited.
* @return True if the vertex is visited.
*/
public boolean isVisited();
/** Connects this vertex and a given vertex with a weighted edge.
* The two vertices cannot be the same, and must not already have
* this edge between them. In a directed graph, the edge points
* towards the given vertex.
* @param endVertex A vertex in the graph that ends the edge.
* @param edgeWeight A real-value edge weight, if any.
* @return True if the edge is added, or false if not.
*/
public boolean connect(VertexInterface<T> endVertex, double edgeWeight);
/** Connects this vertex and given vertex with an unweighted edge.
* The two vertices cannot be the same, and must not already have
* this edge between them. In a directed graph, the edge points towards the
* given vertex.
* @param endVertex A vertex in the graph that ends the edge.
* @return True if the edge is added, or false if not.
*/
public boolean connect(VertexInterface<T> endVertex);
/** Creates an iterator of this vertex's neighbors by following
* all edges that begin at this vertex.
* @return An iterator of the neighboring vertices of this vertex.
*/
public Iterator<VertexInterface<T>> getNeighborIterator();
/** Creates an iterator of the weights of the edges to thisthis
* vertex's neighbors.
* @return An iterator of edge weights of the edges to this vertex's neighbors.
*/
public Iterator<Double> getWeightIterator();
/** Sees whether this vertex has at least one neighbor.
* @return True if the vertex has a neighbor.
*/
public boolean hasNeighbor();
/** Gets an unvisited neighbor, if any, of this vertex.
* @return Either a vertex that is an unvisted neighbor or null if no such
* neighbor exists.
*/
public VertexInterface<T> getUnvistedNeighbor();
/** Records the previous vertex on a path to this vertex.
* @param predecessor The vertex previous to this one along a path.
*/
public void setPredecessor(VertexInterface<T> predecessor);
/** Gets the recorded predecessor of this vertex.
* @return Either this vertex's predecessor or null if no predecessor was recorded.
*/
public VertexInterface<T> getPredecessor();
/** Sees whether a predecessor was recorded for this vertex.
* @return True if a predecessor was recorded.
*/
public boolean hasPredecessor();
/** Records the cost of a path to this vertex.
* @param newCost The cost of the path.
*/
public void setCost(double newCost);
/** Gets the recorded cost of the path to this vertex.
* @return The cost of the path.
*/
public double getCost();
} // end VertexInterface