summaryrefslogtreecommitdiffstats
path: root/src/CS340.TSP/City.cs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-04-22 20:43:24 -0500
committerToby Vincent <tobyv13@gmail.com>2021-04-22 20:43:24 -0500
commit2a5db460a9d9091238f64c48a640aac7cbe40678 (patch)
treea57b990a664e0cf8501660fe2bc5c329fcd16848 /src/CS340.TSP/City.cs
parentf77dd59b7cfe5c8237e5410156dd940bc7d7b069 (diff)
implemented graph printing
Diffstat (limited to 'src/CS340.TSP/City.cs')
-rw-r--r--src/CS340.TSP/City.cs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/CS340.TSP/City.cs b/src/CS340.TSP/City.cs
index 962a864..a64439b 100644
--- a/src/CS340.TSP/City.cs
+++ b/src/CS340.TSP/City.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
using Graph;
using Interfaces;
@@ -16,25 +15,28 @@ namespace TSP
public new double Key { get => this[Parent].Weight; set => Key = value; }
- public Coordinates Location { get; set; }
+ public Coordinate Location { get; set; }
public City() { }
public City(int id) =>
Id = id;
- public City(int id, List<Road> edges) : this(id) =>
- Edges = edges;
-
- public City(IVertex city)
+ public City(int id, List<Road> edges) : this(id)
{
- Id = city.Id;
- Parent = city.Parent;
- foreach (Road edge in city.Edges)
+ foreach (Road edge in edges)
{
Road newEdge = new Road(edge.U, edge.V, edge.Weight);
Edges.Add(newEdge);
}
}
+
+ public City(IVertex city) : this(city.Id, city.Edges) =>
+ Parent = city.Parent;
+
+ public City(IVertex city, Coordinate location) : this(city) =>
+ Location = new Coordinate(location.X, location.Y);
+
+ public City(City city) : this(city, city.Location) { }
}
} \ No newline at end of file