-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdge.java
More file actions
86 lines (75 loc) · 1.5 KB
/
Edge.java
File metadata and controls
86 lines (75 loc) · 1.5 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
/**
* Edge with source, destination and weight information
* @author Saveri
*
*/
public class Edge
{
private Vertex src;
private Vertex dest;
private int wt;
/**
* Constructor to construct an edge between two vertices (i.e source and destination)
*
* @param source - start vertex
* @param destination - end vertex
* @param weight - weight of edge between two vertices
*/
public Edge(int ux, int uy, int vx, int vy, int weight)
{
Vertex u = new Vertex(ux,uy);
Vertex v = new Vertex(vx,vy);
src = u;
dest = v;
wt = weight;
}
/**
* Gets the start vertex of an edge
* @return source vertex
*/
public Vertex getSource()
{
return src;
}
/**
* Gets the end vertex of an edge
* @return end vertex
*/
public Vertex getDestination()
{
return dest;
}
/**
* Gets the weight of an edge
* @return weight of edge
*/
public int getWeight()
{
return wt;
}
/**
* Gets x-coordinate of destination vertex
* @return x-coordinate of destination vertex
*/
public int getDestX()
{
return dest.getX();
}
/**
* Gets y-coordinate of destination vertex
* @return y-coordinate of destination vertex
*/
public int getDestY()
{
return dest.getY();
}
/**
* Returns the name of the edge which constitues the x and y coordinate
* in string format
* @return name of edge
*/
public String getEdgeName()
{
return this.getDestX()+""+this.getDestY();
}
}