Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="G"></param>
        /// <returns>Retorna um grafo coplementar</returns>
        public Grafo getComplementar(GrafoMatriz Gm)
        {
            numVertices = Gm.get_numVertices();
            GrafoLista Gl = new GrafoLista(numVertices);

            for (int i = 0; i < numVertices; ++i)
            {
                for (int j = 0; j < numVertices; j++)
                {
                    if (!Gm.existeAresta(i, j, 1))
                    {
                        Gl.insereAresta(i, j, 1);
                    }
                }
            }


            return(Gl);
        }
Example #2
0
        public GrafoLista grafoTransposto()
        {
            GrafoLista grafoT = new GrafoLista(this.numVertices);

            for (int v = 0; v < this.numVertices; v++)
            {
                if (!this.listaAdjVazia(v))
                {
                    Aresta adj = this.primeiroListaAdj(v);
                    while (adj != null)
                    {
                        grafoT.insereAresta(adj.v2, adj.v1, adj.peso);
                        adj = this.proxAdj(v);
                    }
                }
            }

            return(grafoT);
        }