- Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathUnweightedEdge.cs
70 lines (58 loc) · 1.81 KB
/
UnweightedEdge.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
64
65
66
67
68
69
usingSystem;
usingDataStructures.Common;
namespaceDataStructures.Graphs
{
/// <summary>
/// The graph edge class.
/// </summary>
publicclassUnweightedEdge<TVertex>:IEdge<TVertex>whereTVertex:IComparable<TVertex>
{
privateconstint_edgeWeight=0;
/// <summary>
/// Gets or sets the source vertex.
/// </summary>
/// <value>The source.</value>
publicTVertexSource{get;set;}
/// <summary>
/// Gets or sets the destination vertex.
/// </summary>
/// <value>The destination.</value>
publicTVertexDestination{get;set;}
/// <summary>
/// [PRIVATE MEMBER] Gets or sets the weight.
/// </summary>
/// <value>The weight.</value>
publicInt64Weight
{
get{thrownewNotImplementedException("Unweighted edges don't have weights.");}
set{thrownewNotImplementedException("Unweighted edges can't have weights.");}
}
/// <summary>
/// Gets a value indicating whether this edge is weighted.
/// </summary>
publicboolIsWeighted
{
get
{returnfalse;}
}
/// <summary>
/// CONSTRUCTOR
/// </summary>
publicUnweightedEdge(TVertexsrc,TVertexdst)
{
Source=src;
Destination=dst;
}
#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;
return0;
}
#endregion
}
}