GenRndGnm

GenRndGnm(GraphType, Nodes, Edges, IsDir=True, Rnd=TRnd)

Generates an Erdos-Renyi random graph of the specified GraphType.

Parameters:

  • GraphType: graph class (input)

    Class of output graph – one of PNGraph, PNEANet, or PUNGraph.

  • Nodes: int (input)

    Number of nodes in the generated graph.

  • Edges: int (input)

    Number of edges in the genereated graph.

  • IsDir: bool (input)

    Indicates whether to consider the edges as directed or undirected. Defaults to directed.

  • Rnd: TRnd (input)

    Random number generator.

Return value:

  • graph

    A Snap.py graph of the specified type.

The following example shows how to generate random graphs of types TNGraph, TUNGraph, and TNEANet:

import snap

Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000)
for EI in Graph.Edges():
    print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())

UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000)
for EI in UGraph.Edges():
    print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())

Network = snap.GenRndGnm(snap.PNEANet, 100, 1000)
for EI in Network.Edges():
    print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())

Previous topic

GenTree

Next topic

GenPrefAttach

This Page