Program Listing for File LFRGenerator.hpp

Return to documentation for file (include/networkit/generators/LFRGenerator.hpp)

#ifndef NETWORKIT_GENERATORS_LFR_GENERATOR_HPP_
#define NETWORKIT_GENERATORS_LFR_GENERATOR_HPP_

#include <networkit/base/Algorithm.hpp>
#include <networkit/generators/StaticGraphGenerator.hpp>
#include <networkit/graph/Graph.hpp>
#include <networkit/structures/Partition.hpp>

namespace NetworKit {

class LFRGenerator final : public Algorithm, public StaticGraphGenerator {
public:
    LFRGenerator(count n);

    void setDegreeSequence(std::vector<count> degreeSequence);

    void generatePowerlawDegreeSequence(count avgDegree, count maxDegree, double nodeDegreeExp);

    void setCommunitySizeSequence(std::vector<count> communitySizeSequence);

    void setPartition(Partition zeta);

    void generatePowerlawCommunitySizeSequence(count minCommunitySize, count maxCommunitySize,
                                               double communitySizeExp);

    void setMu(double mu);

    void setMu(const std::vector<double> &mu);

    void setMuWithBinomialDistribution(double mu);

    void run() override;

    Graph generate() override;

    Graph getGraph() const;

    Graph &&getMoveGraph();

    Partition getPartition() const;

    Partition &&getMovePartition();

private:
    /*
     * These methods might be overridden by a sub-class which could use a different model or
     * generator in order to generate the parts of the graph.
     */
    std::vector<std::vector<node>> assignNodesToCommunities();
    Graph generateIntraClusterGraph(std::vector<count> intraDegreeSequence,
                                    const std::vector<node> &localToGlobalNode);
    Graph generateInterClusterGraph(const std::vector<count> &externalDegreeSequence);

    count n;
    bool hasDegreeSequence;
    std::vector<count> degreeSequence;
    bool hasCommunitySizeSequence;
    std::vector<count> communitySizeSequence;
    bool hasInternalDegreeSequence;
    std::vector<count> internalDegreeSequence;
    bool hasGraph;
    Graph G;
    bool hasPartition;
    Partition zeta;
};

} // namespace NetworKit

#endif // NETWORKIT_GENERATORS_LFR_GENERATOR_HPP_