Exemple #1
0
        private IPriorityQueue <DijkstraNode> BuildDijkstraNodes(TW[] weights)
        {
            IPriorityQueue <DijkstraNode> nodes = new CompleteHeap <DijkstraNode>();

            for (int i = 0; i < N; i++)
            {
                if (Status(i) == VStatus.Discovered)
                {
                    nodes.Insert(new DijkstraNode()
                    {
                        Cost = weights[i], Index = i
                    });
                }
            }
            return(nodes);
        }
Exemple #2
0
        private IPriorityQueue <KruskalEdge> BuildEdgeHeap()
        {
            IPriorityQueue <KruskalEdge> edges = new CompleteHeap <KruskalEdge>();

            for (int i = 0; i < N - 1; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    if (Exist(i, j, false))
                    {
                        edges.Insert(new KruskalEdge()
                        {
                            From = i, To = j, Weight = Exist(i, j)?Weight(i, j):Weight(j, i)
                        });
                    }
                }
            }
            return(edges);
        }