コード例 #1
0
 private void AddConnectionLocal(CityNode otherCity, double distance)
 {
     if (!Connections.Any(x => x.ToCity.Equals(otherCity)))
     {
         Debug.WriteLine($"Adding connection from {this} to {otherCity}");
         Connections.Add(new Edge(otherCity, this, distance));
     }
     else
     {
         Debug.WriteLine($"NOT adding connection from {this} to {otherCity}, already exists");
     }
 }
コード例 #2
0
 public Edge(CityNode to, CityNode from, double distance)
 {
     ToCity = to;
     FromCity = from;
     Distance = distance;
 }
コード例 #3
0
 public void AddConnection(CityNode otherCity, double distance)
 {
     AddConnectionLocal(otherCity, distance);
     otherCity.AddConnectionLocal(this, distance);
 }
コード例 #4
0
 private CityNode GetCityNode(string name)
 {
     var node = _cities.FirstOrDefault(x => x.Name.Equals(name));
     if (node == null)
     {
         Debug.WriteLine($"Created new CityNode {name}");
         node = new CityNode(name);
         _cities.Add(node);
     }
     return node;
 }