using System; namespace Code.Lab6 { [Serializable] public class Edge : IComparable { public float cost; public readonly Vertex Vertex; public Edge(Vertex vertex = null, float cost = 1f) { Vertex = vertex; this.cost = cost; } public int CompareTo(Edge other) { var result = cost - other.cost; var idA = Vertex.GetInstanceID(); var idB = other.Vertex.GetInstanceID(); if (idA == idB) return 0; return (int)result; } public bool Equals(Edge other) { return other.Vertex.id == Vertex.id; } public override bool Equals(object obj) { var other = (Edge)obj; return other != null && other.Vertex.id == Vertex.id; } public override int GetHashCode() { return Vertex.GetHashCode(); } } }