From f77dd59b7cfe5c8237e5410156dd940bc7d7b069 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Thu, 22 Apr 2021 02:12:26 -0500 Subject: added Coordinates to City --- src/CS340.Graph | 2 +- src/CS340.TSP/City.cs | 16 ++++------------ src/CS340.TSP/Coordinates.cs | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 src/CS340.TSP/Coordinates.cs (limited to 'src') diff --git a/src/CS340.Graph b/src/CS340.Graph index e3c487f..92abf69 160000 --- a/src/CS340.Graph +++ b/src/CS340.Graph @@ -1 +1 @@ -Subproject commit e3c487f39f44cdecb514fd33e0f5d3f4465451b2 +Subproject commit 92abf69c87475311de8c3d585c352b484aae8e9c 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; using IVertex = IVertex, double>; using Road = Edge; + using Vertex = Vertex, double>; - public class City : IVertex, IComparable + public partial class City : Vertex, IVertex, IComparable { - public int Id { get; set; } - public double Key { get => this[Parent].Weight; set => Key = value; } - public int Parent { get; set; } = -1; - public List Edges { get; set; } = new List(); + 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; + } + } +} -- cgit v1.2.3-70-g09d2