Ejemplo n.º 1
0
        SquareMatrix BuildPartitionMatrix(IList<TreeNode<Element>> nodes)
        {
            SquareMatrix matrix = new SquareMatrix(nodes.Count);

            for (int i = 0; i < nodes.Count; i++)
            {
                Element provider = nodes[i].NodeValue;

                for (int j = 0; j < nodes.Count; j++)
                {
                    if (j != i)
                    {
                        Element consumer = nodes[j].NodeValue;

                        Relation relation = _model.GetRelation(consumer, provider);

                        if (relation != null && relation.Weight > 0)
                        {
                            matrix.Set(i, j, 1);
                        }
                        else
                        {
                            matrix.Set(i, j, 0);
                        }
                    }
                }
            }

            return matrix;
        }
Ejemplo n.º 2
0
        public object Clone()
        {
            SquareMatrix sm = new SquareMatrix(Size);

            for (int i = 0; i < Size; i++)
            {
                for (int j = 0; j < Size; j++)
                {
                    sm.Set(i, j, Get(i, j));
                }
            }

            return(sm);
        }