LoadDyNet

LoadDyNet(FNm)

Loads a directed network in the DyNetML format. Loads only the first network in the file FNm.

Parameters:

  • InFNm: string

    Filename with the description of the graph.

Return value:

  • directed graph TNGraph

    A directed Snap.py graph.

For more info, see ORA Network Analysis Data (http://www.casos.cs.cmu.edu/computational_tools/data2.php)

The following example shows how to get TNGraph object for nodes in TNGraph:

import snap
import sys

GOut = snap.GenRndGnm(snap.TNGraph, 100, 1000)

fname = "test.xml"
f = open(fname, "w")
f.write("<network>\n")

for EI in GOut.Edges():
    src = EI.GetSrcNId()
    dst = EI.GetDstNId()
    f.write("\t<link source='" + str(src) + "' target='" + str(dst) + "'/> \n")

f.write("</network>\n")
f.close()

GIn = snap.LoadDyNet(fname)

if (GIn.GetNodes() == GOut.GetNodes()):
    print("true")