/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NGRandomNetBuilder.h14/// @author Markus Hartinger15/// @author Daniel Krajzewicz16/// @author Michael Behrisch17/// @date Mar, 200318///19// Additional structures for building random nets20/****************************************************************************/21#pragma once22#include <config.h>2324#include <map>25#include <utils/distribution/RandomDistributor.h>26#include "NGNet.h"272829// ===========================================================================30// class definitions31// ===========================================================================32/**33* @class NGRandomNetBuilder34* @brief A class that builds random network using an algorithm by Markus Hartinger.35*36* @todo Describe the algorithm37*/38class NGRandomNetBuilder {39public:40/** @brief Constructor41*42* @param[in] net The network to fill with generated structures43* @param[in] minAngle The minimum allowed angle between two streets44* @param[in] minDistance The minimum allowed distance between two nodes45* @param[in] maxDistance The maximum allowed distance between two nodes46* @param[in] connectivity The connectivity factor47* @param[in] numTries ?48* @todo check meanings of connectivity/numTries49*/50NGRandomNetBuilder(NGNet& net, double minAngle, double minDistance, double maxDistance, double connectivity,51int numTries, const RandomDistributor<int>& neighborDist);52535455/** @brief Builds a NGNet using the set values56*57* @param[in] numNodes Number of iterations (node insertions) to perform58* @todo Describe the algorithm59*/60void createNet(int numNodes, bool gridMode);616263private:64/** @brief Removes the given node from the list of outer nodes65*66* @param[in] node The node to remove67*/68void removeOuterNode(NGNode* node);697071/** @brief Checks whether the angle of this node's connections are valid72*73* Checks whether the connections of the nodes are in common with the value of myMinLinkAngle.74*75* @param[in] node The node to check connections of76* @return Whether the settings allow to connect both nodes77*/78bool checkAngles(const NGNode* const node);798081/** @brief Checks whether connecting the given two nodes complies with the set restrictions82*83* Checks whether the distance, the angle, and the connectivity is within the defined range84* when both nodes would be connected85*86* @param[in] baseNode The first node of the combination to check87* @param[in] newNode The second node of the combination to check88* @return Whether the settings allow to connect both nodes89*/90bool canConnect(NGNode* baseNode, NGNode* newNode);919293/** @brief Creates new random node94*95* Returns true, if creation was successful.96*97* @param[in] baseNode ?98* @todo Describe better99*/100bool createNewNode(NGNode* baseNode, bool gridMode);101102103/** @brief finds possible connections between Node and OuterNodes complying with restrictions104*105* @param[in] node ?106* @todo Describe better107*/108void findPossibleOuterNodes(NGNode* node);109110111private:112/// @brief The network to fill113NGNet& myNet;114115/// @brief The list of outer nodes116NGNodeList myOuterNodes;117118/// @brief The list of outer links119NGEdgeList myOuterLinks;120121// list of possible new connections122NGNodeList myConNodes;123124125/// @name restrictions126//@{127128/// @brief Minimum angle allowed between two links129double myMinLinkAngle;130131/// @brief Minimum distance allowed between two nodes132double myMinDistance;133134/// @brief Maximum distance allowed between two nodes135double myMaxDistance;136137/// @brief Probability of connecting to a existing node if possible138double myConnectivity;139//@}140141142/// @brief Number of tries to create a new node143int myNumTries;144145/// @brief Number of nodes to be created146int myNumNodes;147148/// @brief The distribution of number of neighbours149RandomDistributor<int> myNeighbourDistribution;150151private:152/// @brief Invalidated copy constructor.153NGRandomNetBuilder(const NGRandomNetBuilder&);154155/// @brief Invalidated assignment operator.156NGRandomNetBuilder& operator=(const NGRandomNetBuilder&);157158};159160161