예제 #1
0
        public void MST()
        {
            bool[]    visited = new bool[size];
            ArrayList liste   = new ArrayList();

            listeEkle(0, liste, visited);
            visited[0] = true;
            for (int x = 1; x < size; x++)
            {
                vertexEdge birYol = (vertexEdge)liste[0];
                liste.RemoveAt(0);

                if (!visited[birYol.v2] && visited[birYol.v1])
                {
                    visited[birYol.v2] = true;
                    listeEkle(birYol.v2, liste, visited);
                }
                else if (!visited[birYol.v1] && visited[birYol.v2])
                {
                    visited[birYol.v1] = true;
                    listeEkle(birYol.v1, liste, visited);
                }

                ağaç[birYol.v1, birYol.v2] = 1;
            }
        }
예제 #2
0
        public void ekle(int a, int b, int weight)
        {
            matris[a, b] = weight;
            matris[b, a] = weight;

            vertexEdge yol = new vertexEdge(a, b, weight);

            yollar.Add(yol);
        }