AddSelfEdges

AddSelfEdges()

A graph method that adds a self-edge for every node in a graph.

Parameters:

  • None

Return value:

  • None

The following example shows how to add self edges to every node in TNGraph, TUNGraph, and TNEANet:

import snap

Graph = snap.GenRndGnm(snap.TNGraph, 10, 0)
Graph.AddSelfEdges()
for EI in Graph.Edges():
    print("edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId()))

UGraph = snap.GenRndGnm(snap.TUNGraph, 10, 0)
UGraph.AddSelfEdges()
for EI in UGraph.Edges():
    print("edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId()))

Network = snap.GenRndGnm(snap.TNEANet, 10, 0)
Network.AddSelfEdges()
for EI in Network.Edges():
    print("edge: (%d, %d)" % (EI.GetSrcNId(), EI.GetDstNId()))