Beispiel #1
0
        static void leerGrafo()
        {
            string archivoTxt = Path.Combine(Directory.GetCurrentDirectory(), "adyacencia.txt");

            string[] lines = File.ReadAllLines(archivoTxt);
            Console.WriteLine(lines.Length);
            grafo = new AdjacencyList(int.Parse(lines[0]));
            foreach (var i in lines)
            {
                string[] j = i.Split(',');
                int      x = int.Parse(j[0]);
                try{
                    grafo.agregaVertice(int.Parse(j[0]), int.Parse(j[1]), int.Parse(j[2]));
                }catch (Exception) {      //PARA EVITAR LA PRIMERA LINEA QUE ES EL NUMERO DE NODOS
                    continue;
                }
            }
        }
Beispiel #2
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);
        }