public MatrizDispersa MuliplyBy(MatrizDispersa matriz)
        {
            MatrizDispersa resultado = new MatrizDispersa();

            for (int c = 0; c < this.SizeX; c++)
            {
                PosicionMatriz posx = new PosicionMatriz(c);
                PosicionMatriz col  = (PosicionMatriz)resultado.columna.Add(posx);



                for (int f = 0; f < matriz.SizeY; f++)
                {
                    int total = 0;
                    for (int j = 0; j < this.SizeY; j++)
                    {
                        int res1 = GetValueAt(matriz, j, c);
                        int res2 = GetValueAt(this, c, j);
                        total += res1 * res2;
                    }
                    col.filas.Add(new PosicionMatriz(c, f, total.ToString()));
                }
            }
            return(resultado);
        }
        public void Print(MatrizDispersa matriz)
        {
            string nodes = "";

            PosicionMatriz it = (PosicionMatriz)matriz.columna.primero;

            do
            {
                nodes += $" subgraph col{it.posx}" + "{ \n rank=UD; \n";

                PosicionMatriz fila = (PosicionMatriz)it.filas.primero;

                do
                {
                    nodes += $"\n col{((PosicionMatriz)fila).posx}fil{((PosicionMatriz)fila).posy}[label={fila.valor}]";
                    nodes += $"\n col{((PosicionMatriz)fila).posx}fil{((PosicionMatriz)fila).posy}->col{((PosicionMatriz)fila.Siguiente).posx}fil{((PosicionMatriz)fila.Siguiente).posy}; ";

                    fila = (PosicionMatriz)fila.Siguiente;
                }while (fila != it.filas.primero);
                nodes += " } ";

                it = (PosicionMatriz)it.Siguiente;
            }while (it != matriz.columna.primero);
            string output = @"digraph dibujo{node[shape=box width=1];rank=LR; " + nodes + " }";

            Random random = new Random();
            int    i      = random.Next();

            string newstr       = i.ToString();
            string path         = $@"C:\EDD\PrimeraPractica\output\";
            string combinedPath = Path.Combine(path, $"graph{newstr}.dot");

            // This text is added only once to the file.
            if (!File.Exists(combinedPath))
            {
                // Create a file to write to.
                File.WriteAllText(combinedPath, output);
            }

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("dot.exe");
            startInfo.WindowStyle     = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.Arguments       = $@"-Tbmp {combinedPath} -o { Path.Combine(path, $"outfile{newstr}.bmp")}";
            startInfo.UseShellExecute = false;
            process.StartInfo         = startInfo;
            process.Start();
            process.WaitForExit();


            System.Diagnostics.Process.Start(Path.Combine(path, $"outfile{newstr}.bmp"));
        }
Example #3
0
        private void button5_Click(object sender, EventArgs e)
        {
            MatrizDispersa cola = new MatrizDispersa(_usuarioActual.cola.Dequeue());
            MatrizDispersa pila = new MatrizDispersa(_usuarioActual.pila.Pop());

            if (cola.SizeY == pila.SizeX)
            {
                MatrizDispersa result = cola.MuliplyBy(pila);
                result.Print(result);
            }
            else
            {
                MessageBox.Show("Dimensiones de Matriz Invalidas!");
            }
        }
Example #4
0
        public void Print()
        {
            string nodes = "";

            Nodo t     = inicio;
            int  index = 0;

            while (t != null)
            {
                Matriz         ma  = (Matriz)t;
                MatrizDispersa mat = new MatrizDispersa(ma);
                nodes += $"\n rank=LR; col{index++}[label={mat.GetAllSumValues()}]; ";

                t = t.Siguiente;
            }
            string output = @"digraph dibujo{node[shape=box width=1]; " + nodes + " }";

            Random random = new Random();
            int    i      = random.Next();

            string newstr       = i.ToString();
            string path         = $@"C:\EDD\PrimeraPractica\output\";
            string combinedPath = Path.Combine(path, $"graph{newstr}.dot");

            // This text is added only once to the file.
            if (!File.Exists(combinedPath))
            {
                // Create a file to write to.
                File.WriteAllText(combinedPath, output);
            }

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo("dot.exe");
            startInfo.WindowStyle     = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.Arguments       = $@"-Tbmp {combinedPath} -o { Path.Combine(path, $"outfile{newstr}.bmp")}";
            startInfo.UseShellExecute = false;
            process.StartInfo         = startInfo;
            process.Start();
            process.WaitForExit();


            System.Diagnostics.Process.Start(Path.Combine(path, $"outfile{newstr}.bmp"));
        }
        public int GetValueAt(MatrizDispersa matriz, int x, int y)
        {
            PosicionMatriz colMz = (PosicionMatriz)matriz.columna.primero;

            do
            {
                if (colMz.posx == x)
                {
                    PosicionMatriz filaMz = (PosicionMatriz)colMz.filas.primero;
                    do
                    {
                        if (filaMz.posy == y)
                        {
                            return(Int32.Parse(filaMz.valor));
                        }

                        filaMz = (PosicionMatriz)filaMz.Siguiente;
                    } while (filaMz != colMz.filas.primero);
                }
                colMz = (PosicionMatriz)colMz.Siguiente;
            } while (colMz != matriz.columna.primero);
            return(0);
        }
Example #6
0
        private void button6_Click(object sender, EventArgs e)
        {
            MatrizDispersa ma = new MatrizDispersa(_usuarioActual.pila.Peek());

            ma.Print(ma);
        }
Example #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            MatrizDispersa peekCola = new  MatrizDispersa(_usuarioActual.cola.Peek());

            peekCola.Print(peekCola);
        }