static public Caminhos[] montaarestas(int ncidades, Telescopio[] telesc)
        {
            int aux = 0, aux2, aux3 = 0;
            int npontes = (ncidades * (ncidades - 1)) / 2;
            var pontes  = new Caminhos[npontes];

            while (aux < ncidades)
            {
                aux2 = aux + 1;
                while (aux2 < ncidades)
                {
                    pontes[aux3] = new Caminhos(aux, aux2)
                    {
                        dist = Distance(telesc[aux].Latitude, telesc[aux].Longitude, telesc[aux2].Latitude, telesc[aux2].Longitude)
                    };
                    aux3++; aux2++;
                }
                aux++;
            }
            return(pontes);
        }
 public Caminhos(Caminhos x)
 {
     a    = x.a;
     b    = x.b;
     dist = x.dist;
 }
        static public void radixsort(int ncidades, Caminhos[] v, Telescopio[] mapa)
        {
            int npontes = (ncidades * (ncidades - 1)) / 2;
            int digitos = 5, divisor = 1, aux = 0, aux2 = 0, aux3 = 0, basenum = 10, aux4;

            int[] contador = new int[basenum];
            while (aux < digitos)
            {
                Caminhos[] vetor = new Caminhos[npontes];
                aux2 = 0;
                if (aux == 4)
                {
                    basenum = 3;
                }
                while (aux2 < basenum)
                {
                    contador[aux2] = 0;
                    aux2++;
                }
                aux2 = 0;
                while (aux2 < npontes)
                {
                    aux3 = (v[aux2].dist / divisor) % 10;
                    if (aux3 == 0)
                    {
                        vetor[contador[0]] = new Caminhos(v[aux2]);
                    }
                    contador[aux3]++;
                    aux2++;
                }
                aux2 = 1;
                while (aux2 < basenum)
                {
                    contador[aux2] += contador[aux2 - 1];
                    aux2++;
                }
                aux2 = 0;
                while (aux2 < npontes)
                {
                    aux3 = (v[aux2].dist / divisor) % 10;
                    if (aux3 != 0)
                    {
                        vetor[contador[aux3 - 1]] = new Caminhos(v[aux2]);
                        contador[aux3 - 1]++;
                    }
                    aux2++;
                }
                aux2 = 0;
                while (aux2 < npontes)
                {
                    if (aux != 4)
                    {
                        v[aux2] = vetor[aux2];
                    }
                    else
                    {
                        aux3 = vetor[aux2].a;
                        aux4 = mapa[aux3].contador;
                        mapa[aux3].ordemdistancia[aux4]   = vetor[aux2].dist;
                        mapa[aux3].ordemcidade[aux4]      = vetor[aux2].b;
                        mapa[aux3].posicao[vetor[aux2].b] = aux4;
                        mapa[aux3].contador++;
                        aux3 = vetor[aux2].b;
                        aux4 = mapa[aux3].contador;
                        mapa[aux3].ordemdistancia[aux4]   = vetor[aux2].dist;
                        mapa[aux3].ordemcidade[aux4]      = vetor[aux2].a;
                        mapa[aux3].posicao[vetor[aux2].a] = aux4;
                        mapa[aux3].contador++;
                    }
                    aux2++;
                }
                if (aux == 4)
                {
                    aux2 = 0;
                    while (aux2 < ncidades)
                    {
                        mapa[aux2].contador = 1;
                        aux2++;
                    }
                }
                aux++;
                divisor *= 10;
            }
        }