Program Listing for File PubWebGenerator.hpp

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

/*
 * PubWebGenerator.hpp
 *
 *  Created on: Apr 10, 2013
 *      Author: Henning
 */

#ifndef NETWORKIT_GENERATORS_PUB_WEB_GENERATOR_HPP_
#define NETWORKIT_GENERATORS_PUB_WEB_GENERATOR_HPP_

#include <vector>

#include <networkit/generators/StaticGraphGenerator.hpp>
#include <networkit/graph/Graph.hpp>
#include <networkit/viz/Point.hpp>

namespace NetworKit {

class PubWebGenerator final : public StaticGraphGenerator {
    friend class DynamicPubWebGenerator;

public:
    PubWebGenerator() {
    } // nullary constructor needed for Python Shell - do not use this to construct instance
    ~PubWebGenerator() override = default;

    PubWebGenerator(count numNodes, count numberOfDenseAreas, coordinate neighborhoodRadius,
                    count maxNumberOfNeighbors);

    Graph generate() override;

    const std::vector<Point2D> &getCoordinates() const { return coordinates; }
    std::vector<Point2D> moveCoordinates() { return std::move(coordinates); }

private:
    struct circle {
        coordinate x;
        coordinate y;
        coordinate rad;
    };

    static constexpr coordinate MAX_DENSE_AREA_RADIUS = 0.2;
    static constexpr coordinate MIN_MAX_DENSE_AREA_FACTOR = 5.0;
    static constexpr edgeweight BASE_WEIGHT = 0.01;

    count n;
    count numDenseAreas;
    coordinate neighRad;
    count maxNeigh;
    std::vector<circle> denseAreaXYR;
    std::vector<count> numPerArea;
    std::vector<Point2D> coordinates;

    Point2D intoUnitSquare(Point2D pt) const noexcept;
    coordinate squaredDistanceInUnitTorus(Point2D pt1, Point2D pt2) const noexcept;

    void determineNeighbors(Graph &g);
    void chooseDenseAreaSizes();
    void fillDenseAreas(Graph &g);
    void spreadRemainingNodes(Graph &g);
    void chooseClusterSizes();
    void addNodesToArea(index area, count num, Graph &g);

    void addNode(Graph &g);
};

} /* namespace NetworKit */
#endif // NETWORKIT_GENERATORS_PUB_WEB_GENERATOR_HPP_