public GrafoDirigidoCopia(List <string> entrada) { foreach (string ent in entrada) { if (ent.Contains("#")) { this.totalVerticesGrafo = int.Parse(ent.Substring(1, ent.Length - 1)); } else { string[] vet = ent.Split(';'); Vertice v1 = vet[0].Equals("") ? null : new Vertice(vet[0]); Vertice v2 = vet[1].Equals("") ? null : new Vertice(vet[1]); double peso = vet[2].Equals("") ? 0 : double.Parse(vet[2]); int dir = vet[3].Equals("") ? 0 : int.Parse(vet[3]); Aresta aresta = null; if (dir == -1) { aresta = new Aresta(v1, v2, peso); } else if (dir == 1) { aresta = new Aresta(v1, v2, peso); } this.vertices.Add(aresta); } } }
public GrafoNaoDirigido(List <string> entradas) { foreach (string ent in entradas) { if (ent.Contains("#")) { this.totalVerticesGrafo = int.Parse(ent.Substring(1, ent.Length - 1)); } else { string[] vetor = ent.Split(';'); Vertice vertice = vetor[0].Equals("") ? null : new Vertice(vetor[0]); Vertice vertice2 = vetor[1].Equals("") ? null : new Vertice(vetor[1]); double peso = vetor[2].Equals("") ? 0 : double.Parse(vetor[2]); Aresta aresta = new Aresta(vertice, vertice2, peso); this.vertices.Add(aresta); } } }