Exemplo n.º 1
0
        public void RemoveComponente(IComponente Componente)
        {
            if (Componente == null)
            {
                return;
            }

            Aresta aresta = (Aresta)Componente;

            if (Componentes.Contains(Componente))
            {
                DistanciaTotal = DistanciaTotal - aresta.Distancia;
                Componentes.Remove(aresta);
            }
        }
Exemplo n.º 2
0
        public void AddComponente(IComponente Componente)
        {
            if (Componente == null)
            {
                return;
            }

            Aresta aresta = (Aresta)Componente;

            if (!Componentes.Contains(Componente))
            {
                DistanciaTotal = DistanciaTotal + aresta.Distancia;
                Componentes.Add(aresta);
            }
        }
Exemplo n.º 3
0
        public override IComponente EscolheMelhorComponente(List <IComponente> Componentes)
        {
            Aresta melhor = (Aresta)Componentes.FirstOrDefault();

            foreach (Aresta aresta in Componentes)
            {
                if (melhor != null)
                {
                    if ((int)melhor.Valor < (int)aresta.Valor)
                    {
                        melhor = aresta;
                    }
                }
            }
            return(melhor);
        }
Exemplo n.º 4
0
        bool VerificaSeJaFoiVizitado(Aresta a)
        {
            if (a.CidadeDestino.Equals(CidadeInicial))
            {
                if (VerticesJaVisitados.Count == QtdeCidades)
                {
                    return(false);
                }
            }

            foreach (Vertice cidade in VerticesJaVisitados)
            {
                if (a.CidadeDestino.Equals(cidade))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 5
0
        public override IComponente EscolheMelhorComponente(List <IComponente> Componentes)
        {
            Aresta melhor = (Aresta)Componentes.FirstOrDefault();

            foreach (Aresta aresta in Componentes)
            {
                if (melhor != null)
                {
                    if ((int)melhor.Valor < (int)aresta.Valor)
                    {
                        melhor = aresta;
                    }
                }
            }
            if (melhor != null)
            {
                VerticesJaVisitados.Enqueue(melhor.CidadeDestino);
            }

            return(melhor);
        }
Exemplo n.º 6
0
        bool VerificaSeJaFoiVizitado(Aresta a)
        {
            if (a.CidadeDestino.Equals(CidadeInicial))
                if (VerticesJaVizitados.Count == QtdeCidades)
                    return false;

            foreach (Vertice cidade in VerticesJaVizitados)
                if (a.CidadeDestino.Equals(cidade))
                    return true;
            return false;
        }
Exemplo n.º 7
0
 public void AddAresta(Aresta aresta)
 {
     Arestas.Add(aresta);
 }
Exemplo n.º 8
0
 public void AddAresta(Aresta aresta)
 {
     Arestas.Add(aresta);
 }