summaryrefslogtreecommitdiffstats
path: root/src/CS340.TSP/City.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CS340.TSP/City.cs')
-rw-r--r--src/CS340.TSP/City.cs25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/CS340.TSP/City.cs b/src/CS340.TSP/City.cs
index 1a38e2c..eaf4ef3 100644
--- a/src/CS340.TSP/City.cs
+++ b/src/CS340.TSP/City.cs
@@ -6,8 +6,11 @@ using Interfaces;
namespace TSP
{
+ using INode = INode<double>;
+ using IVertex = IVertex<Edge<double>, double>;
+ using Road = Edge<double>;
- public class City : IVertex<Road, double>, IComparable<INode<double>>
+ public class City : IVertex, IComparable<INode>
{
public int Id { get; set; }
public double Key { get => this[Parent].Weight; set => Key = value; }
@@ -26,28 +29,18 @@ namespace TSP
public City(int id, List<Road> edges) : this(id) =>
Edges = edges;
- public City(City vertex)
+ public City(IVertex city)
{
- Id = vertex.Id;
- Parent = vertex.Parent;
- foreach (Road edge in vertex.Edges)
- {
- Road newEdge = new Road(edge.U, edge.V, edge.Weight);
- Edges.Add(newEdge);
- }
- }
- public City(Vertex<Edge<double>, double> vertex)
- {
- Id = vertex.Id;
- Parent = vertex.Parent;
- foreach (Edge<double> edge in vertex.Edges)
+ Id = city.Id;
+ Parent = city.Parent;
+ foreach (Road edge in city.Edges)
{
Road newEdge = new Road(edge.U, edge.V, edge.Weight);
Edges.Add(newEdge);
}
}
- public int CompareTo(INode<double> node) =>
+ public int CompareTo(INode node) =>
Key.CompareTo(node.Key);
public override string ToString() => $"{Id} {String.Join(" ", Edges.Select(e => (e.V, e.Weight)))}";