blob: 962a86425f8f4aeb43f51df063431ba492ceb9d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
using System;
using System.Collections.Generic;
using System.Linq;
using Graph;
using Interfaces;
namespace TSP
{
using INode = INode<double>;
using IVertex = IVertex<Edge<double>, double>;
using Road = Edge<double>;
using Vertex = Vertex<Edge<double>, double>;
public partial class City : Vertex, IVertex, IComparable<INode>
{
public new double Key { get => this[Parent].Weight; set => Key = value; }
public Coordinates 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)
{
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);
}
}
}
}
|