Program Listing for File DegreePreservingShuffle.hpp

Return to documentation for file (include/networkit/randomization/DegreePreservingShuffle.hpp)

/*
 * DegreePreservingShuffle.hpp
 *
 *  Created on: 21.08.2018
 *      Author: Manuel Penschuck <networkit@manuel.jetzt>
 */

#ifndef NETWORKIT_RANDOMIZATION_DEGREE_PRESERVING_SHUFFLE_HPP_
#define NETWORKIT_RANDOMIZATION_DEGREE_PRESERVING_SHUFFLE_HPP_

#include <networkit/base/Algorithm.hpp>
#include <networkit/graph/Graph.hpp>

namespace NetworKit {

class DegreePreservingShuffle final : public Algorithm {
public:
    DegreePreservingShuffle() = delete;

    explicit DegreePreservingShuffle(const Graph &G);

    ~DegreePreservingShuffle() override;

    void run() final;

    Graph getGraph() const;

    const std::vector<node> &getPermutation() const noexcept { return permutation; }

    static Graph shuffleGraph(const Graph &input) {
        DegreePreservingShuffle algo(input);
        algo.run();
        return algo.getGraph();
    }

private:
    const Graph *G;
    std::vector<node> permutation;
};

} // namespace NetworKit

#endif // NETWORKIT_RANDOMIZATION_DEGREE_PRESERVING_SHUFFLE_HPP_