/// <summary> /// Checks if node is part of <see cref="AllNeighbors"/>, by identifier. /// </summary> /// <param name="identifier">Node identifier.</param> public void CheckIfPartOfAllNeighborsByIdentifier(string identifier) { if (AllNeighbors.Find(x => x.Identifier == identifier) == null) { throw new System.ArgumentException("Node not found among AllNeighbors field."); } }
/// <summary> /// Adds connection to node with <paramref name="identifier"/> in <see cref="ConnectedNeighbors"/>. /// </summary> /// <param name="identifier">Neighboring node identifier.</param> public void AddConnectionByIdentifier(string identifier) { CheckIfPartOfAllNeighborsByIdentifier(identifier); // if this goes through, connection is appropriate MazeNode neighbor = AllNeighbors.Find(x => x.Identifier == identifier); AddConnectionByReference(neighbor); //if (!ConnectedNeighbors.Contains(neighbor)) { ConnectedNeighbors.Add(neighbor); } //if (!neighbor.ConnectedNeighbors.Contains(this)) { neighbor.ConnectedNeighbors.Add(this); } }
/// <summary> /// Adds connection to <paramref name="neighbor"/> in <see cref="AllNeighbors"/>. /// </summary> /// <param name="neighbor">Neighboring node.</param> public void AddBaseConnectionByReference(MazeNode neighbor) { if (AllNeighbors.Find(x => x.Identifier == neighbor.Identifier) == null) { AllNeighbors.Add(neighbor); } if (neighbor.AllNeighbors.Find(x => x.Identifier == this.Identifier) == null) { neighbor.AllNeighbors.Add(this); } }