Esempio n. 1
0
        //7->0,3,1->2,6->4,5
        public static AdjacencyList CyclicGraph8Nodes()
        {
            AdjacencyList h = new AdjacencyList(8);

            h.agregaVertice(0, 1, 3);
            h.agregaVertice(0, 2, 5);
            h.agregaVertice(0, 3, 2);
            h.agregaVertice(0, 7, 10);
            h.agregaVertice(1, 0, 3);
            h.agregaVertice(1, 2, 5);
            h.agregaVertice(1, 4, 4);
            h.agregaVertice(1, 6, 6);
            h.agregaVertice(1, 3, 8);
            h.agregaVertice(1, 7, 6);
            h.agregaVertice(2, 0, 5);
            h.agregaVertice(2, 1, 5);
            h.agregaVertice(2, 6, 9);
            h.agregaVertice(2, 4, 1);
            h.agregaVertice(2, 5, 7);
            h.agregaVertice(3, 7, 14);
            h.agregaVertice(3, 0, 2);
            h.agregaVertice(3, 1, 8);
            h.agregaVertice(3, 4, 12);
            h.agregaVertice(4, 2, 1);
            h.agregaVertice(4, 1, 4);
            h.agregaVertice(4, 3, 12);
            h.agregaVertice(4, 6, 15);
            h.agregaVertice(5, 1, 7);
            h.agregaVertice(5, 7, 9);
            h.agregaVertice(6, 1, 6);
            h.agregaVertice(6, 2, 9);
            h.agregaVertice(6, 4, 15);
            h.agregaVertice(6, 7, 3);
            h.agregaVertice(7, 0, 10);
            h.agregaVertice(7, 5, 9);
            h.agregaVertice(7, 1, 6);
            h.agregaVertice(7, 6, 3);
            h.agregaVertice(7, 3, 14);
            h.mostrarListaAdyacencia();
            return(h);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            leerGrafo();
            grafo.mostrarListaAdyacencia();
            //grafo = CyclicGraph8Nodes();
            camino = new List <int>();
            inicializarArrVisitados(8);
            int raiz = 1;
            //SE BUSCA EN TODOS LOS VECINOS UN CAMINO
            var nodosVecinos = grafo[raiz];
            int nodoInicial  = raiz;
            var res          = 0;

            camino.Clear();
            visitados[raiz] = true;
            res             = busqueda(raiz, raiz);
            if (res == 200)
            {
                imprimirCamino(camino);
                Console.WriteLine($"Costo del camino : {costo}");
            }
            Console.WriteLine("Hello World!");
        }