diff options
author | Toby Vincent <tobyv13@gmail.com> | 2021-04-22 02:12:26 -0500 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2021-04-22 02:12:26 -0500 |
commit | f77dd59b7cfe5c8237e5410156dd940bc7d7b069 (patch) | |
tree | 67f3aefeb6fd488091ca882eec5917243cfd26ef /src/CS340.TSP | |
parent | 29213f627ee0091a2a9a952e4ab3017896fe382a (diff) |
added Coordinates to City
Diffstat (limited to 'src/CS340.TSP')
-rw-r--r-- | src/CS340.TSP/City.cs | 16 | ||||
-rw-r--r-- | src/CS340.TSP/Coordinates.cs | 17 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/CS340.TSP/City.cs b/src/CS340.TSP/City.cs index eaf4ef3..962a864 100644 --- a/src/CS340.TSP/City.cs +++ b/src/CS340.TSP/City.cs @@ -9,17 +9,14 @@ namespace TSP using INode = INode<double>; using IVertex = IVertex<Edge<double>, double>; using Road = Edge<double>; + using Vertex = Vertex<Edge<double>, double>; - public class City : IVertex, IComparable<INode> + public partial class City : Vertex, IVertex, IComparable<INode> { - public int Id { get; set; } - public double Key { get => this[Parent].Weight; set => Key = value; } - public int Parent { get; set; } = -1; - public List<Road> Edges { get; set; } = new List<Road>(); + public new double Key { get => this[Parent].Weight; set => Key = value; } - // indexer for accessing edge with v of index - public Road this[int index] { get => Edges.Find(edge => edge.V == index); } + public Coordinates Location { get; set; } public City() { } @@ -39,10 +36,5 @@ namespace TSP Edges.Add(newEdge); } } - - public int CompareTo(INode node) => - Key.CompareTo(node.Key); - - public override string ToString() => $"{Id} {String.Join(" ", Edges.Select(e => (e.V, e.Weight)))}"; } }
\ No newline at end of file diff --git a/src/CS340.TSP/Coordinates.cs b/src/CS340.TSP/Coordinates.cs new file mode 100644 index 0000000..f377c89 --- /dev/null +++ b/src/CS340.TSP/Coordinates.cs @@ -0,0 +1,17 @@ +using Graph; +using Interfaces; + +namespace TSP +{ + public struct Coordinates + { + public double X { get; set; } + public double Y { get; set; } + + public Coordinates(double x, double y) + { + X = x; + Y = y; + } + } +} |