Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        public GrafoDirigido(List <string> entrada)
        {
            foreach (string ent in entrada)
            {
                if (entrada.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;

                    aresta = new Aresta(v1, v2, peso, dir);
                    this.vertices.Add(aresta);
                }
            }
        }
Пример #3
0
 public Aresta(Vertice v1, Vertice v2, double peso, int direcao)
 {
     this.direcao        = direcao;
     this.verticeFinal   = v2;
     this.verticeInicial = v1;
 }
Пример #4
0
 public Aresta(Vertice v1, Vertice v2, double peso)
 {
     this.verticeInicial = v1;
     this.verticeFinal   = v2;
     this.peso           = peso;
 }