Example #1
0
    public ITraversable[] GetConnectedTraversables()
    {
        List <ITraversable> tn = new List <ITraversable>();

        foreach (Node nd in pipeNodeData.GetNeighbors())
        {
            tn.Add(nd.GetInformation <ITraversable>()[0]);
        }

        return(tn.ToArray());
    }
Example #2
0
        // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
        public int TradeNeighbors(Node a_neighbor)
        {
            if (a_neighbor == null)
            {
                return(-1);
            }
            else if (!m_neighbors.Contains(a_neighbor))
            {
                return(-2);
            }

            Node[] myNeighbors;


            // // Remove eachother as neighbors, so they aren't neighbors to themselves
            // RemoveNeighbor(a_neighbor);
            // a_neighbor.RemoveNeighbor(this);

            // Save this node neighbors to a temp array
            myNeighbors = m_neighbors.ToArray();


            ClearNeighbors();                               // Clear this node's neighbors
            foreach (Node n in a_neighbor.GetNeighbors())   // For each neighbor of my neighbor
            {
                AddNeighbor(n);                             // Copy it to this node's neighbors
            }
            AddNeighbor(a_neighbor);                        // Add the neighbor back to this node's neighbors


            a_neighbor.ClearNeighbors();                    // Clear the neighbor's neighbors
            foreach (Node n in myNeighbors)                 // For each node in the temp array
            {
                a_neighbor.AddNeighbor(n);                  // Copy it to the neighbor's new neighbors
            }
            a_neighbor.AddNeighbor(this);                   // Add this node back to the neighbor's neighbors

            return(0);
        }