Ejemplo n.º 1
0
        public static DirectedGraphMatrixInc ConvertToSMatrixInc(DirectedGraphList from)
        {
            int sumc = 0;

            for (int i = 0; i < from.NodesNr; i++)
            {
                sumc += from.CountElem(i);
            }
            int c = 0;
            DirectedGraphMatrixInc x = new DirectedGraphMatrixInc(from.NodesNr, sumc);

            for (int i = 0; i < from.NodesNr; i++)//pobiera po kolei elementy, dodaje do matrixinc i usuwa z listy
            {
                for (int j = 0; j < from.NodesNr; j++)
                {
                    if (from.GetConnection(i, j))
                    {
                        x.setWeight(i, j, from.getWeight(i, j));
                        x.MakeConnection(i, j, c);
                        c++;
                        from.RemoveConnection(i, j);
                    }
                }
            }
            return(x);
        }
Ejemplo n.º 2
0
        /// SKIEROWANE KONWERSJE

        public static DirectedGraphMatrix ConvertToSMatrix(DirectedGraphMatrixInc from)
        {
            DirectedGraphMatrix x = new DirectedGraphMatrix(from.NodesNr);

            for (int i = 0; i < from.NodesNr; i++)
            {
                for (int j = 0; j < from.NodesNr; j++)
                {
                    if (from.GetConnection(i, j))
                    {
                        x.MakeConnection(i, j);
                    }
                    x.setWeight(i, j, from.getWeight(i, j));
                }
            }
            return(x);
        }