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"); } }
public Edge(CityNode to, CityNode from, double distance) { ToCity = to; FromCity = from; Distance = distance; }
public void AddConnection(CityNode otherCity, double distance) { AddConnectionLocal(otherCity, distance); otherCity.AddConnectionLocal(this, distance); }
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; }