Generates a graph with star topology. Node id 0 is in the center and then links to all other nodes.
Parameters:
Class of output graph – one of PNGraph, PNEANet, or PUNGraph.
Number of nodes in the star graph, including the center node.
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 a star graph with five nodes using GenStar() for classes TNGraph, TUNGraph, and TNEANet:
import snap
Graph = snap.GenStar(snap.PNGraph, 5, True)
for EI in Graph.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
UGraph = snap.GenStar(snap.PUNGraph, 5, True)
for EI in UGraph.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())
Network = snap.GenStar(snap.PNEANet, 5, True)
for EI in Network.Edges():
print "edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId())