summaryrefslogtreecommitdiffstats
path: root/src/CS340.TSP/Tour.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/CS340.TSP/Tour.cs')
-rw-r--r--src/CS340.TSP/Tour.cs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/CS340.TSP/Tour.cs b/src/CS340.TSP/Tour.cs
index 27ab5a5..a4ef10f 100644
--- a/src/CS340.TSP/Tour.cs
+++ b/src/CS340.TSP/Tour.cs
@@ -11,9 +11,14 @@ namespace TSP
public List<City> Cities { get; set; } = new List<City>();
public double Weight
{
- get => Cities
- .Where(city => city.Parent != -1)
- .Sum(city => city.Key);
+ get
+ {
+ if (Cities.Count == 0)
+ return double.MaxValue;
+
+ return Cities.Where(city => city.Parent != -1)
+ .Sum(city => city.Key);
+ }
}
// indexer: get vertex where vertex.Id == index