Program Listing for File MocnikGenerator.hpp

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

/*
 * MocnikGenerator.hpp
 *
 * Created on: July 7, 2018
 * Author: Franz-Benjamin Mocnik <mail@mocnik-science.net>
 */

#ifndef NETWORKIT_GENERATORS_MOCNIK_GENERATOR_HPP_
#define NETWORKIT_GENERATORS_MOCNIK_GENERATOR_HPP_

#include <networkit/generators/StaticGraphGenerator.hpp>

namespace NetworKit {

class MocnikGenerator final : public StaticGraphGenerator {
    // GENERAL DATA

    std::vector<std::vector<double>> nodePositions;

    // DATA FOR EACH LAYER

    using NodeCollection = std::vector<node>;

    using CellArray = std::vector<NodeCollection>;

    struct LayerState {
        CellArray a;
        int aMax;
    };

    // FUNCTIONS RELATED TO THE LAYER STATE

    void initCellArray(LayerState &s, count numberOfCellsPerDimension);

    NodeCollection getNodes(LayerState &s, int i);

    void addNode(LayerState &s, int j);

    int toIndex(LayerState &s, const std::vector<double> &v);

    int toIndex(LayerState &s, const std::vector<int> &v);

    std::vector<int> fromIndex(LayerState &s, int i);

    std::vector<int> boxSurface(LayerState &s, int i, int r);

    std::vector<int> boxVolume(LayerState &s, int j, double r);

    // EDGE GENERATION

    void addEdgesToGraph(Graph &G, count n, double k, double relativeWeight, bool baseLayer);

    count dim;
    std::vector<count> ns;
    std::vector<double> ks;
    bool weighted;
    std::vector<double> relativeWeights;

public:
    MocnikGenerator(count dim, count n, double k, bool weighted = false);
    MocnikGenerator(count dim, std::vector<count> ns, double k, bool weighted = false);
    MocnikGenerator(count dim, std::vector<count> ns, std::vector<double> ks,
                    bool weighted = false);
    MocnikGenerator(count dim, count n, double k, std::vector<double> weighted);
    MocnikGenerator(count dim, std::vector<count> ns, double k, std::vector<double> weighted);
    MocnikGenerator(count dim, std::vector<count> ns, std::vector<double> ks,
                    std::vector<double> weighted);

    Graph generate() override;
};

} /* namespace NetworKit */
#endif // NETWORKIT_GENERATORS_MOCNIK_GENERATOR_HPP_