addRandomEdges

directedNetwork.addRandomEdges (m, edge=weightedEdge) undirectedNetwork.addRandomEdges (m, edge=weightedEdge)

Add edges with randomly chosen source and target nodes until the network reaches a certain mean degree. Self connections and parallel (duplicate) edges are avoided.

Parameters

m: float
Nodes are added until the mean degree of the network reaches m.
edge: edge template
Every added edge is a copy of this template.

Example (python-conedy)

import conedy as co


N = co.undirectedNetwork()

for i in range (0,100):
      N.addNode(co.node())

N.addRandomEdges (10.0, co.weightedEdge(0.5))

print "should be 10:" + str(N.meanDegree())
print "should be false:" + str(N.isDirected())

N.setDirected();

N.addRandomEdges (20.0, co.weightedEdge (0.5))

print "should be 20:" + str(N.meanDegree())
print "should be true:" + str(N.isDirected())

Example (conedy)

undirectedNetwork n;

loop (100) n.addNode(node());

n.addRandomEdges (10.0, weightedEdge(0.5));

print "should be 10:" + n.meanDegree();
print "should be true:" + n.isDirected();

n.setDirected();

n.addRandomEdges (20.0, weightedEdge (0.5));

print "should be 20:" + n.meanDegree();
print "should be true:" + n.isDirected();

Table Of Contents

Previous topic

addNode

Next topic

addRandomEdgesDegreeDistribution