forked from aalhour/C-Sharp-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
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
using System;
using DataStructures.Common;
namespace DataStructures.Graphs
{
/// <summary>
/// The graph edge class.
/// </summary>
public class UnweightedEdge<TVertex> : IEdge<TVertex> where TVertex : IComparable<TVertex>
{
private const int _edgeWeight = 0;
/// <summary>
/// Gets or sets the source vertex.
/// </summary>
/// <value>The source.</value>
public TVertex Source { get; set; }
/// <summary>
/// Gets or sets the destination vertex.
/// </summary>
/// <value>The destination.</value>
public TVertex Destination { get; set; }
/// <summary>
/// [PRIVATE MEMBER] Gets or sets the weight.
/// </summary>
/// <value>The weight.</value>
public Int64 Weight
{
get { throw new NotImplementedException("Unweighted edges don't have weights."); }
set { throw new NotImplementedException("Unweighted edges can't have weights."); }
}
/// <summary>
/// Gets a value indicating whether this edge is weighted.
/// </summary>
public bool IsWeighted
{
get
{ return false; }
}
/// <summary>
/// CONSTRUCTOR
/// </summary>
public UnweightedEdge(TVertex src, TVertex dst)
{
Source = src;
Destination = dst;
}
#region IComparable implementation
public int CompareTo(IEdge<TVertex> other)
{
if (other == null)
return -1;
bool areNodesEqual = Source.IsEqualTo<TVertex>(other.Source) && Destination.IsEqualTo<TVertex>(other.Destination);
if (!areNodesEqual)
return -1;
return 0;
}
#endregion
}
}