/// <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); } }
/// <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); }
/// <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); }
/// <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)); }