Program Listing for File KruskalMSF.hpp

Return to documentation for file (include/networkit/graph/KruskalMSF.hpp)

/*
 * KruskalMSF.hpp
 *
 *  Created on: 03.09.2015
 *      Author: Henning
 */

#ifndef NETWORKIT_GRAPH_KRUSKAL_MSF_HPP_
#define NETWORKIT_GRAPH_KRUSKAL_MSF_HPP_

#include <networkit/Globals.hpp>
#include <networkit/graph/Graph.hpp>
#include <networkit/graph/SpanningForest.hpp>

namespace NetworKit {

class KruskalMSF final : public SpanningForest {
public:
    KruskalMSF(const Graph &G);

    void run() override;

    edgeweight getTotalWeight() const {
        assureFinished();
        if (G->isWeighted())
            return totalWeight;
        else
            return static_cast<edgeweight>(forest.numberOfEdges());
    }

private:
    edgeweight totalWeight = 0.0;
};

} /* namespace NetworKit */
#endif // NETWORKIT_GRAPH_KRUSKAL_MSF_HPP_