Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NGRandomNetBuilder Class Reference

A class that builds random network using an algorithm by Markus Hartinger. More...

#include <NGRandomNetBuilder.h>

Collaboration diagram for NGRandomNetBuilder:
[legend]

Public Member Functions

void createNet (int numNodes, bool gridMode)
 Builds a NGNet using the set values.
 
 NGRandomNetBuilder (NGNet &net, double minAngle, double minDistance, double maxDistance, double connectivity, int numTries, const RandomDistributor< int > &neighborDist)
 Constructor.
 

Private Member Functions

bool canConnect (NGNode *baseNode, NGNode *newNode)
 Checks whether connecting the given two nodes complies with the set restrictions.
 
bool checkAngles (const NGNode *const node)
 Checks whether the angle of this node's connections are valid.
 
bool createNewNode (NGNode *baseNode, bool gridMode)
 Creates new random node.
 
void findPossibleOuterNodes (NGNode *node)
 finds possible connections between Node and OuterNodes complying with restrictions
 
void removeOuterNode (NGNode *node)
 Removes the given node from the list of outer nodes.
 

Private Attributes

NGNodeList myConNodes
 
NGNetmyNet
 The network to fill.
 
NGEdgeList myOuterLinks
 The list of outer links.
 
NGNodeList myOuterNodes
 The list of outer nodes.
 

restrictions

double myMinLinkAngle
 Minimum angle allowed between two links.
 
double myMinDistance
 Minimum distance allowed between two nodes.
 
double myMaxDistance
 Maximum distance allowed between two nodes.
 
double myConnectivity
 Probability of connecting to a existing node if possible.
 
int myNumTries
 Number of tries to create a new node.
 
int myNumNodes
 Number of nodes to be created.
 
RandomDistributor< int > myNeighbourDistribution
 The distribution of number of neighbours.
 
 NGRandomNetBuilder (const NGRandomNetBuilder &)
 Invalidated copy constructor.
 
NGRandomNetBuilderoperator= (const NGRandomNetBuilder &)
 Invalidated assignment operator.
 

Detailed Description

A class that builds random network using an algorithm by Markus Hartinger.

Todo:
Describe the algorithm

Definition at line 39 of file NGRandomNetBuilder.h.

Constructor & Destructor Documentation

◆ NGRandomNetBuilder() [1/2]

NGRandomNetBuilder::NGRandomNetBuilder ( NGNet net,
double  minAngle,
double  minDistance,
double  maxDistance,
double  connectivity,
int  numTries,
const RandomDistributor< int > &  neighborDist 
)

Constructor.

Parameters
[in]netThe network to fill with generated structures
[in]minAngleThe minimum allowed angle between two streets
[in]minDistanceThe minimum allowed distance between two nodes
[in]maxDistanceThe maximum allowed distance between two nodes
[in]connectivityThe connectivity factor
[in]numTries?
Todo:
check meanings of connectivity/numTries

Definition at line 39 of file NGRandomNetBuilder.cpp.

◆ NGRandomNetBuilder() [2/2]

NGRandomNetBuilder::NGRandomNetBuilder ( const NGRandomNetBuilder )
private

Invalidated copy constructor.

Member Function Documentation

◆ canConnect()

bool NGRandomNetBuilder::canConnect ( NGNode baseNode,
NGNode newNode 
)
private

Checks whether connecting the given two nodes complies with the set restrictions.

Checks whether the distance, the angle, and the connectivity is within the defined range when both nodes would be connected

Parameters
[in]baseNodeThe first node of the combination to check
[in]newNodeThe second node of the combination to check
Returns
Whether the settings allow to connect both nodes

Definition at line 99 of file NGRandomNetBuilder.cpp.

References checkAngles(), Position::distanceTo2D(), NGNode::getPosition(), PositionVector::intersects(), GeomHelper::INVALID_OFFSET, PositionVector::length(), myMaxDistance, myMinDistance, myOuterLinks, GeomHelper::nearest_offset_on_line_to_point2D(), and PositionVector::positionAtOffset2D().

Referenced by createNet(), createNewNode(), and findPossibleOuterNodes().

Here is the caller graph for this function:

◆ checkAngles()

bool NGRandomNetBuilder::checkAngles ( const NGNode *const  node)
private

Checks whether the angle of this node's connections are valid.

Checks whether the connections of the nodes are in common with the value of myMinLinkAngle.

Parameters
[in]nodeThe node to check connections of
Returns
Whether the settings allow to connect both nodes

Definition at line 60 of file NGRandomNetBuilder.cpp.

References GeomHelper::angle2D(), NGNode::getLinks(), NGNode::getPosition(), myMinLinkAngle, Position::x(), and Position::y().

Referenced by canConnect().

Here is the caller graph for this function:

◆ createNet()

void NGRandomNetBuilder::createNet ( int  numNodes,
bool  gridMode 
)

Builds a NGNet using the set values.

Parameters
[in]numNodesNumber of iterations (node insertions) to perform
Todo:
Describe the algorithm

Definition at line 207 of file NGRandomNetBuilder.cpp.

References NGNet::add(), canConnect(), createNewNode(), findPossibleOuterNodes(), NGNode::getLinks(), NGNode::getMaxNeighbours(), NGNet::getNextFreeID(), myConnectivity, myConNodes, myNet, myNumNodes, myNumTries, myOuterLinks, myOuterNodes, NGNet::nodeNo(), RandHelper::rand(), removeOuterNode(), NGNode::setMaxNeighbours(), NGNode::setX(), and NGNode::setY().

Referenced by buildNetwork().

Here is the caller graph for this function:

◆ createNewNode()

bool NGRandomNetBuilder::createNewNode ( NGNode baseNode,
bool  gridMode 
)
private

Creates new random node.

Returns true, if creation was successfull.

Parameters
[in]baseNode?
Todo:
Describe better

Definition at line 169 of file NGRandomNetBuilder.cpp.

References NGNet::add(), canConnect(), RandomDistributor< T >::get(), NGNode::getLinks(), NGNode::getMaxNeighbours(), NGNet::getNextFreeID(), NGNode::getPosition(), M_PI, MAX2(), myMaxDistance, myMinDistance, myNeighbourDistribution, myNet, myOuterLinks, myOuterNodes, RandHelper::rand(), removeOuterNode(), NGNode::setMaxNeighbours(), NGNode::setX(), NGNode::setY(), Position::x(), and Position::y().

Referenced by createNet().

Here is the caller graph for this function:

◆ findPossibleOuterNodes()

void NGRandomNetBuilder::findPossibleOuterNodes ( NGNode node)
private

finds possible connections between Node and OuterNodes complying with restrictions

Parameters
[in]node?
Todo:
Describe better

Definition at line 151 of file NGRandomNetBuilder.cpp.

References canConnect(), NGNode::connected(), NGNode::getLinks(), NGNode::getMaxNeighbours(), myConNodes, and myOuterNodes.

Referenced by createNet().

Here is the caller graph for this function:

◆ operator=()

NGRandomNetBuilder & NGRandomNetBuilder::operator= ( const NGRandomNetBuilder )
private

Invalidated assignment operator.

◆ removeOuterNode()

void NGRandomNetBuilder::removeOuterNode ( NGNode node)
private

Removes the given node from the list of outer nodes.

Parameters
[in]nodeThe node to remove

Definition at line 49 of file NGRandomNetBuilder.cpp.

References myOuterNodes.

Referenced by createNet(), and createNewNode().

Here is the caller graph for this function:

Field Documentation

◆ myConnectivity

double NGRandomNetBuilder::myConnectivity
private

Probability of connecting to a existing node if possible.

Definition at line 139 of file NGRandomNetBuilder.h.

Referenced by createNet().

◆ myConNodes

NGNodeList NGRandomNetBuilder::myConNodes
private

Definition at line 123 of file NGRandomNetBuilder.h.

Referenced by createNet(), and findPossibleOuterNodes().

◆ myMaxDistance

double NGRandomNetBuilder::myMaxDistance
private

Maximum distance allowed between two nodes.

Definition at line 136 of file NGRandomNetBuilder.h.

Referenced by canConnect(), and createNewNode().

◆ myMinDistance

double NGRandomNetBuilder::myMinDistance
private

Minimum distance allowed between two nodes.

Definition at line 133 of file NGRandomNetBuilder.h.

Referenced by canConnect(), and createNewNode().

◆ myMinLinkAngle

double NGRandomNetBuilder::myMinLinkAngle
private

Minimum angle allowed between two links.

Definition at line 130 of file NGRandomNetBuilder.h.

Referenced by checkAngles().

◆ myNeighbourDistribution

RandomDistributor<int> NGRandomNetBuilder::myNeighbourDistribution
private

The distribution of number of neighbours.

Definition at line 150 of file NGRandomNetBuilder.h.

Referenced by createNewNode().

◆ myNet

NGNet& NGRandomNetBuilder::myNet
private

The network to fill.

Definition at line 114 of file NGRandomNetBuilder.h.

Referenced by createNet(), and createNewNode().

◆ myNumNodes

int NGRandomNetBuilder::myNumNodes
private

Number of nodes to be created.

Definition at line 147 of file NGRandomNetBuilder.h.

Referenced by createNet().

◆ myNumTries

int NGRandomNetBuilder::myNumTries
private

Number of tries to create a new node.

Definition at line 144 of file NGRandomNetBuilder.h.

Referenced by createNet().

◆ myOuterLinks

NGEdgeList NGRandomNetBuilder::myOuterLinks
private

The list of outer links.

Definition at line 120 of file NGRandomNetBuilder.h.

Referenced by canConnect(), createNet(), and createNewNode().

◆ myOuterNodes

NGNodeList NGRandomNetBuilder::myOuterNodes
private

The list of outer nodes.

Definition at line 117 of file NGRandomNetBuilder.h.

Referenced by createNet(), createNewNode(), findPossibleOuterNodes(), and removeOuterNode().


The documentation for this class was generated from the following files: