Пример #1
0
        /// <summary>
        /// Adds all the possible neighbors for a given <see cref="BaseIntersection"/>.
        /// </summary>
        /// <param name="intersection">The given intersection.</param>
        private void AddNeighbor(BaseIntersection intersection)
        {
            // Gets a list with all the possible IDs of the neighbors.
            var possibleNeighbors = this.neighborsDictionary[intersection.ID];

            // Gets all the actual existing neighbors (checks for every possible neighbors if it exists).
            var existingNeighbors =
                this.Intersections.Where(inter => possibleNeighbors.Contains(inter.ID)).Select(i => i);
            foreach (var inter in existingNeighbors)
            {
                intersection.AddNeighbor(inter);
                inter.AddNeighbor(intersection);
            }
        }