Пример #1
0
        public virtual void Set(IGraphMatrix other)
        {
            NodesNr = other.NodesNr;
            connect = new int[NodesNr, NodesNr];
            weights = new int[NodesNr, NodesNr];

            for (int y = 0; y < NodesNr; ++y)
            {
                for (int x = 0; x < NodesNr; ++x)
                {
                    if (other.GetConnection(x, y))
                    {
                        MakeConnection(x, y);
                        int weight = other.getWeight(x, y);
                        setWeight(x, y, weight);
                    }
                }
            }

            Columns = other.Columns;
        }
Пример #2
0
 public bool Equals(IGraphMatrix other)
 {
     if (other == null)
     {
         return(false);
     }
     if (this.NodesNr != other.NodesNr)
     {
         return(false);
     }
     for (int i = 0; i < nodesNr; i++)
     {
         for (int j = 0; j < nodesNr; j++)
         {
             if (this.GetConnection(i, j) != other.GetConnection(i, j))
             {
                 return(false);
             }
         }
     }
     return(true);
 }