- Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathWeightedEdge.cs
63 lines (53 loc) · 1.63 KB
/
WeightedEdge.cs
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
usingSystem;
usingDataStructures.Common;
namespaceDataStructures.Graphs
{
/// <summary>
/// The graph weighted edge class.
/// </summary>
publicclassWeightedEdge<TVertex>:IEdge<TVertex>whereTVertex:IComparable<TVertex>
{
/// <summary>
/// Gets or sets the source.
/// </summary>
/// <value>The source.</value>
publicTVertexSource{get;set;}
/// <summary>
/// Gets or sets the destination.
/// </summary>
/// <value>The destination.</value>
publicTVertexDestination{get;set;}
/// <summary>
/// Gets or sets the weight of edge.
/// </summary>
/// <value>The weight.</value>
publicInt64Weight{get;set;}
/// <summary>
/// Gets a value indicating whether this edge is weighted.
/// </summary>
publicboolIsWeighted
{
get{returntrue;}
}
/// <summary>
/// CONSTRUCTOR
/// </summary>
publicWeightedEdge(TVertexsrc,TVertexdst,Int64weight)
{
Source=src;
Destination=dst;
Weight=weight;
}
#region IComparable implementation
publicintCompareTo(IEdge<TVertex>other)
{
if(other==null)
return-1;
boolareNodesEqual=Source.IsEqualTo<TVertex>(other.Source)&&Destination.IsEqualTo<TVertex>(other.Destination);
if(!areNodesEqual)
return-1;
returnWeight.CompareTo(other.Weight);
}
#endregion
}
}