Program Listing for File RmatGenerator.hpp

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

/*
 * RmatGenerator.hpp
 *
 *  Created on: 18.03.2014
 *      Author: Henning
 */

#ifndef NETWORKIT_GENERATORS_RMAT_GENERATOR_HPP_
#define NETWORKIT_GENERATORS_RMAT_GENERATOR_HPP_

#include <stdint.h>
#include <networkit/generators/StaticGraphGenerator.hpp>
#include <networkit/graph/Graph.hpp>

namespace NetworKit {

class RmatGenerator final : public StaticGraphGenerator {
    count scale;
    count edgeFactor;
    double defaultEdgeWeight;
    bool weighted;
    count reduceNodes;
    bool discardSelfLoops;

    // Data for the alias table:
    std::vector<std::pair<uint32_t, uint32_t>> bits;
    std::vector<uint8_t> numberOfBits;
    std::vector<uint32_t> coinFlipProbability;
    std::vector<uint32_t> coinFlipReplacement;
    uint32_t mask;
    std::pair<uint32_t, uint32_t> curBits{0, 0};
    uint32_t remainingBits = 0;

public:
    RmatGenerator(count scale, count edgeFactor, double a, double b, double c, double d,
                  bool weighted = false, count reduceNodes = 0, bool discardSelfLoops = true);

    Graph generate() override;

private:
    std::pair<node, node> sampleEdge(uint8_t bits);
};

} /* namespace NetworKit */
#endif // NETWORKIT_GENERATORS_RMAT_GENERATOR_HPP_