Beispiel #1
0
 /// <summary>
 /// Disconnect from other city.
 /// </summary>
 /// <param name="city">City to disconnect.</param>
 public void Disconnect(TSPCity <D> city)
 {
     if (linkMap.ContainsKey(city))
     {
         linkMap.Remove(city);
         city.Disconnect(this);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Recieve distance between this and other city.
 /// </summary>
 /// <param name="city">Other City.</param>
 /// <returns>Distance or null if there is no connection.</returns>
 public TSPDistance GetDistanceTo(TSPCity <D> city)
 {
     if (linkMap.ContainsKey(city))
     {
         return(this.linkMap[city]);
     }
     return(null);
 }
Beispiel #3
0
 /// <summary>
 /// Connect with other city.
 /// </summary>
 /// <param name="city">Other city.</param>
 /// <param name="distance">Distance between cities.</param>
 /// <returns>Is connection succeed?</returns>
 public bool Connect(TSPCity <D> city, D distance)
 {
     if (!linkMap.ContainsKey(city))
     {
         linkMap[city] = distance;
         city.Connect(this, distance);
         return(true);
     }
     return(false);
 }
Beispiel #4
0
 /// <summary>
 /// Check existance of connection with other city.
 /// </summary>
 /// <param name="city">Other city.</param>
 /// <returns>Is connected?</returns>
 public bool IsConnectedTo(TSPCity <D> city)
 {
     return(this.linkMap.ContainsKey(city));
 }