| WeightedEdge.java |
1 /**
2 * @author Nick Peters
3 * COMP 469 - Search
4 * Creates a randomly generated graph and finds the shortest path between two
5 * random vertices.
6 */
7
8 package search;
9
10 public class WeightedEdge {
11 // The weight of the edge
12 private Integer m_weight;
13 // Determines whether or not the edge is on the shortest
14 private boolean m_path;
15 // The two vertices in the edge.
16 private MyVertex m_src;
17 private MyVertex m_dest;
18 public WeightedEdge(int weight, MyVertex src, MyVertex dest) {
19 m_weight = weight;
20 m_src = src;
21 m_dest = dest;
22 }
23
24 public Integer getWeight() {
25 return m_weight;
26 }
27
28 // If the edge is on the shortest path, then we want to want to mark the
29 // vertices it connects as being on the shortest path.
30 public void setPath() {
31 m_path = true;
32 m_src.setPath();
33 m_dest.setPath();
34 }
35
36 public boolean getPath() {
37 return m_path;
38 }
39
40 public String toString() {
41 return m_weight.toString();
42 }
43 }
44