Generates a two-dimensional graph of rows and columns specified by Rows and Cols parameters.
Parameters:
Class of output graph – one of PNGraph, PNEANet, or PUNGraph.
Specifies number of rows for graph.
Specifies number of columns for graph.
Indicates whether the edges should be directed or undirected. Defaults to directed.
Return value:
A Snap.py graph of the specified type.
The following example shows how to generate grid graphs for classes TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenGrid(snap.PNGraph, 10, 12, False)
for EI in Graph.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
UGraph = snap.GenGrid(snap.PUNGraph, 10, 12, False)
for EI in UGraph.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
Network = snap.GenGrid(snap.PNEANet, 10, 12, False)
for EI in Network.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())