summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-04-22 02:12:26 -0500
committerToby Vincent <tobyv13@gmail.com>2021-04-22 02:12:26 -0500
commitf77dd59b7cfe5c8237e5410156dd940bc7d7b069 (patch)
tree67f3aefeb6fd488091ca882eec5917243cfd26ef
parent29213f627ee0091a2a9a952e4ab3017896fe382a (diff)
added Coordinates to City
m---------src/CS340.Graph0
-rw-r--r--src/CS340.TSP/City.cs16
-rw-r--r--src/CS340.TSP/Coordinates.cs17
3 files changed, 21 insertions, 12 deletions
diff --git a/src/CS340.Graph b/src/CS340.Graph
-Subproject e3c487f39f44cdecb514fd33e0f5d3f4465451b
+Subproject 92abf69c87475311de8c3d585c352b484aae8e9
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;
+ }
+ }
+}