def q2_3(): print("============") g = load_graph_weights() v_mat = cal_initial_feature(g) for k in range(2): v_mat = aggregrate(v_mat, g) v_9 = v_mat[9] cos_sim = [(i, cal_cos_sim(v_9, v)) for i, v in enumerate(v_mat)] cos_sim.sort(key=lambda y: y[1], reverse=True) cos_sims = [u[1] for u in cos_sim] plt.hist(cos_sims, bins=20) plt.title("distribution of cosine similarity") plt.show() node_1, sim_1 = find_node(0, 0.05, cos_sim) subg_1 = get_2_nd_subgraph(node_1, g) subg_1_h = snap.TIntStrH() subg_1_h[node_1] = "blue" subg_1 = snap.ConvertSubGraph(snap.PUNGraph, g, subg_1) snap.DrawGViz(subg_1, snap.gvlNeato, "subgraph_1.png", "subgraph 1 sim: {0}".format(round(sim_1, 2)), True, subg_1_h) node_2 = 9 #find_node(0.4, 0.45, cos_sim) subg_2 = get_2_nd_subgraph(node_2, g) subg_2_h = snap.TIntStrH() subg_2_h[node_2] = "blue" subg_2 = snap.ConvertSubGraph(snap.PUNGraph, g, subg_2) snap.DrawGViz(subg_2, snap.gvlNeato, "subgraph_center_9.png", "subgraph_center_9", True, subg_2_h) node_3, sim_3 = find_node(0.6, 0.65, cos_sim) subg_3 = get_2_nd_subgraph(node_3, g) subg_3_h = snap.TIntStrH() subg_3_h[node_3] = "blue" subg_3 = snap.ConvertSubGraph(snap.PUNGraph, g, subg_3) snap.DrawGViz(subg_3, snap.gvlNeato, "subgraph_3.png", "subgraph 3 sim: {0}".format(round(sim_3, 2)), True, subg_3_h) node_4, sim_4 = find_node(0.9, 0.95, cos_sim) subg_4 = get_2_nd_subgraph(node_4, g) subg_4_h = snap.TIntStrH() subg_4_h[node_4] = "blue" subg_4 = snap.ConvertSubGraph(snap.PUNGraph, g, subg_4) snap.DrawGViz(subg_4, snap.gvlNeato, "subgraph_4.png", "subgraph 4 sim: {0}".format(round(sim_4, 2)), True, subg_4_h) print("============")
def drawGraph(self,labelDict,theGraph,graphName): labels = snap.TIntStrH() for NI in theGraph.Nodes(): thekey=self.nid2id[NI.GetId()] labels[NI.GetId()] = str(labelDict[thekey]) snap.DrawGViz(theGraph, snap.gvlSfdp, graphName, " ", labels)
def GVizTest(NNodes, NEdges): Graph = snap.GenRndGnm(NNodes, NEdges, 1) FName = "test.png" snap.DrawGViz(Graph, 1, snap.TStr(FName), snap.TStr("Snap Ringo Dot"), 1) return os.path.exists(FName)
def DrawGraph(lower, upper, cos_sim, g, filename, title='', color='blue'): """ output the graph """ sub = GetSubgraph(FindNode(lower, upper, cos_sim), g) whole_graph = snap.TIntStrH() whole_graph[sub[0]] = color sub = snap.ConvertSubGraph(snap.PUNGraph, g, sub) snap.DrawGViz(sub, snap.gvlNeato, filename, title, True, whole_graph)
def main(): graphs, names = load_networks(IN_FOLDER) for g, n in zip(graphs, names): NIdColorH = snap.TIntStrH() if g.GetNodes() < 1000: for i in g.Nodes(): NIdColorH[i.GetId()] = "red" snap.DrawGViz(g, snap.gvlCirco, OUT_FOLDER + n + ".png", n, False, NIdColorH)
def plot_subgraph(graph, nodes, output, title): node_ids_vector = snap.TIntV() labels = snap.TIntStrH() for pair in nodes: if pair[0] not in node_ids_vector: node_ids_vector.Add(pair[0]) pkg = graph.GetStrAttrDatN(pair[0], "pkg") labels[pair[0]] = ellipsize_text(pkg, 30) subgraph = snap.GetSubGraph(graph, node_ids_vector) snap.DrawGViz(subgraph, snap.gvlNeato, output, title, labels)
def save_graph(self): labels = snap.TIntStrH() filled_nodes = self.assignment.keys() # assert(len(filled_nodes) > 0) for i in range(self.graph.GetNodes()): if i in filled_nodes: labels[i] = str(i) + ": " + self.assignment[i] else: labels[i] = str(i) + ": " snap.DrawGViz(self.graph, snap.gvlDot, "assignment.png", " ", labels)
def GraphVisualization(G1): labels = snap.TIntStrH() # page_name = snap.TIntStrH() # page_type = snap.TIntStrH() for NI in G1.Nodes(): labels[NI.GetId()] = str(NI.GetId()) # page_name[NI.GetId()] = str(targets['page_name'][NI.GetId()]) # page_type[NI.GetId()] = str(targets['page_type'][NI.GetId()]) snap.DrawGViz(G1, snap.gvlDot, "output.png", " ", labels)
def main(): cosine_dists = get_cosine_dist() Graph = snap.TUNGraph.New() name_to_id = add_nodes(Graph) for pair in cosine_dists: if cosine_dists[pair] > 0.5: Graph.AddEdge(name_to_id[pair[0]], name_to_id[pair[1]]) labels = snap.TIntStrH() for name in name_to_id: labels[name_to_id[name]] = name snap.DrawGViz(Graph, snap.gvlDot, OUTPUT_GRAPH, " ", labels)
def PlotSubGraph(G,NodeID,path="./graph/"): Node = G.GetNI(NodeID) NIdV = snap.TIntV() #subgraph nodes ID NIdV.Add(NodeID) Deg = Node.GetDeg() NidName = snap.TIntStrH() NidName[NodeID] = str(NodeID) for i in range(Deg): NbrID = Node.GetNbrNId(i) NIdV.Add(NbrID) NidName[NbrID] = str(NbrID) SubGraph = snap.GetSubGraph(G, NIdV) snap.DrawGViz(SubGraph,snap.gvlDot,path+"subgraph"+str(NodeID)+".png","SubGraph of "+str(NodeID),NidName) return 0
def visualize_graph(file_egdes, file_img, list_comunity): graph = snap.LoadEdgeList(snap.PUNGraph, file_egdes, 0, 1, '\t') NIdColorH = snap.TIntStrH() colors = ["red", "yellow", "brown", "blue", "green", "pink", "indigo", "antiquewhite","chocolate", "purple", "sienna4", "powderblue", "violet" ] num_color = len(colors) for i, comunity in enumerate(list_comunity): if len(comunity) ==1: NIdColorH[comunity[0]]= "white" else: index = i%num_color for node in comunity: NIdColorH[node] = colors[index] snap.DrawGViz(graph, snap.gvlNeato, file_img, "graph top 200 nodes", True, NIdColorH)
def visualiseGraph(rowData, activityCodeList, fileName, title, undirect_conversion=False): columnList = generateTransition(activityCodeList) G1 = snap.TNGraph.New() checkActivityList = [] for i in columnList: if i[1] in rowData.index: if rowData[i[1]] > 0: if i[0][0] not in checkActivityList: G1.AddNode(i[0][0]) checkActivityList.append(i[0][0]) if i[0][1] not in checkActivityList: G1.AddNode(i[0][1]) checkActivityList.append(i[0][1]) G1.AddEdge(i[0][0],i[0][1]) if undirect_conversion: G1 = snap.ConvertGraph(snap.PUNGraph,G1) snap.DrawGViz(G1, snap.gvlDot, "graphs/" + "/" + fileName + ".png", title, True)
def run(self, filename, claimantList, title='title'): # First to select Insured nodes self.hirachical() Nodes1 = snap.TIntFltH() snap.GetPageRank(self.G, Nodes1) for NI in self.G.Nodes(): if NI.GetId() in self.community: bucket = 0 elif NI.GetId() in claimantList: bucket = 2 else: bucket = self.segDegree(NI.GetInDeg()) # hacked 'col' in Pajek for network metrics if NI.GetId() not in self.nameList: name, _ = self.weighted_choice(bucket) self.nameList[NI.GetId()] = name else: name = self.nameList[NI.GetId()] if name.split('_')[0] == 'ClaimID': col = 5.0 else: col = Nodes1[NI.GetId()] * 2000 if self.printLabel: self.labels[NI.GetId()] = name else: self.labels[NI.GetId()] = str(NI.GetId()) self.NIdColorH[NI.GetId()] = str(col) snap.DrawGViz(self.G, self.layout, '{}/{}.png'.format(PLOT_DIR, filename), title, self.labels, self.NIdColorH) snap.SavePajek(self.G, '{}/{}.net'.format(SAVE_DIR, filename), self.NIdColorH, self.labels)
def load(graphName, snapFileName, pickleFileName): print "hi" try: G = load_graph(snapFileName) with open(pickleFileName, 'rb+') as input: node_dict = pickle.load(input) internetwork_edges = pickle.load(input) print('Done!') print node_dict print type(G) filename, fileextension = os.path.splitext(snapFileName) imageFilePath = "snapData/static/graphimages/" + graphName.replace( " ", "") + ".png" if not os.path.isfile(imageFilePath): snap.DrawGViz(G, snap.gvlSfdp, imageFilePath, "Graph of " + graphName, True) print G, node_dict, internetwork_edges except IOError: print('Could not save node network!') return G, node_dict, internetwork_edges
import snap import sys import math import matplotlib matplotlib.use('Agg') length = len(sys.argv) import matplotlib.pyplot as plt import numpy as np #checking if input is correctly given if length == 1: print "Please enter a file" sys.exit() elif length == 2: input_file = sys.argv[1] else: print "Please enter only one file" sys.exit() #loading the graph given Graph = snap.LoadEdgeList(snap.PUNGraph, input_file, 0, 1) labels = snap.TIntStrH() for NI in Graph.Nodes(): labels[NI.GetId()] = str(NI.GetId()) snap.DrawGViz(Graph, snap.gvlDot, "output.png", " ", labels)
import snap G = snap.TNGraph.New() G.AddNode(1) G.AddNode(2) G.AddNode(3) G.AddNode(4) G.AddEdge(1, 2) G.AddEdge(2, 3) G.AddEdge(1, 3) G.AddEdge(2, 4) G.AddEdge(3, 4) S = snap.TIntStrH() S.AddDat(1, "David") S.AddDat(2, "Emma") S.AddDat(3, "Jim") S.AddDat(4, "Sam") snap.DrawGViz(G, snap.gvlDot, "gviz.png", "Graph", S)
import snap def print_nodes(G): for node in G.Nodes(): print "node id %d, out-degree %d, in-degree %d" % (node.GetId(), node.GetOutDeg(), node.GetInDeg()) def build_legend(filename): legend = snap.TIntStrH() with open(filename) as f: for line in f: tokens = line.split() if not tokens[0].isdigit(): continue # Ignore the first line key = int(tokens[0]) legend[key] = ' '.join(tokens[1:]) return legend print 'Loading edge list...' G = snap.LoadEdgeList(snap.PNGraph, 'ingredient_substitutes.txt', 0, 1) print_nodes(G) print 'Building legend...' legend = build_legend('ingredient_key.txt') print len(legend) print 'Drawing graph...' snap.DrawGViz(G, snap.gvlDot, 'G.png', 'G', legend) # # snap.PlotInDegDistr(G, 'BLAH', 'BLAH in degree')
def generate_graph(df): # set up 3 python dictionaries # roads_and_regions stores the roads and an array of all the regions that each road passes through roads_and_regions = {} # regions_to_traffic stores all the regions and their related traffic data regions_to_traffic = {} # region_array stores a list of all of the regions region_array = [] # region_to_index stores each region to its related index in the spreadsheet # this is for the edges when making the graph region_to_index = {} G1 = snap.TUNGraph.New() # store all of the labels label = snap.TIntStrH() # store all of the colours for the heat map NIdColourH = snap.TIntStrH() # note that the reason one graph cannot contain the colours and the labels is because the two lines # of code above are the same data type and the snap.DrawGViz function cannot determine which is which # go along each row in the data frame for index, row in df.iterrows(): # if the local authority has not already been seen, add it to region_array, region_to_index, the graph (G1), # regions_to_traffic and store the label if not search_array(row['local_authority_name'], region_array): region_array.append(row['local_authority_name']) region_to_index[row['local_authority_name']] = index G1.AddNode(index) label[index] = row['local_authority_name'] regions_to_traffic[row['local_authority_name']] = int( row['all_motor_vehicles']) # otherwise, add the traffic count to the regions_to_traffic dictionary else: t = int(regions_to_traffic[row['local_authority_name']]) + int( row['all_motor_vehicles']) regions_to_traffic[row['local_authority_name']] = t # if we have not seen this road before in the roads_and_regions dictionary, add it to the dictionary if not row['road_name'] in roads_and_regions: # make it an array so that the dictionary stores arrays and not strings # this allows us to use "append" later on temp = [row['local_authority_name']] roads_and_regions[row['road_name']] = temp # if we have already seen this road before in the dictionary, check to see if we already know that the # road has passed through this region else: if not search_array(row['local_authority_name'], roads_and_regions[row['road_name']]): roads_and_regions[row['road_name']].append( row['local_authority_name']) # for each of the roads in the roads_and_regions dictionary... for road in roads_and_regions: n = 0 temp = roads_and_regions[road] for i in roads_and_regions[road]: # start at the second element, if there is one, and make a link between that element # and the one before, repeat this process if n > 0: G1.AddEdge(region_to_index[i], region_to_index[temp[n - 1]]) n += 1 # for each of the regions in the regions_to_traffic dictionary... for region in regions_to_traffic: # set the colour to whatever the node_colour function decides based on the traffic data NIdColourH[region_to_index[region]] = node_colour( regions_to_traffic[region]) # draw both graphs snap.DrawGViz(G1, snap.gvlNeato, "graph.png", header, True, NIdColourH) snap.DrawGViz(G1, snap.gvlNeato, "output.png", header, label)
s = f.read() s1 = re.split('\n', s) G1 = snap.PUNGraph.New() a = re.split(' ', s1[0]) for i in range(0, int(a[0])): G1.AddNode(i) for i in range(1, int(a[1]) + 1): b = re.split(' ', s1[i]) G1.AddEdge(int(b[0]), int(b[1])) DegCentr = dict() for NI in G1.Nodes(): DegCentr[NI.GetId()] = snap.GetDegreeCentr(G1, NI.GetId()) # print "node: %d centrality: %f" % (NI.GetId(), DegCentr) # print DegCentr[15232] EdgePara = dict() for i in range(1, int(a[1]) + 1): c = re.split(' ', s1[i]) EdgePara[(int(c[0]), int(c[1]))] = DegCentr[int( c[0])] / (DegCentr[int(c[0])] + DegCentr[int(c[1])]) EdgePara[(int(c[1]), int(c[0]))] = DegCentr[int( c[1])] / (DegCentr[int(c[0])] + DegCentr[int(c[1])]) snap.DrawGViz(G1, snap.gvlNeato, "graph_undirected.png", "graph 2", True)
#for node in delNodeList: # G.DelNode(node) #EdgeCount = snap.CntEdgesToSet(G, nodeID, nodeSet) #print "Number of edges from %d to NodeSet in PNGraph = %d" % (nodeID, EdgeCount) with open("fansTop100.csv", "w") as outer: writer = csv.writer(outer, lineterminator='\n') writer.writerow(["id", "user", "count", "link"]) for i in range(100): item = userEdgeCount[i] id = item[0] user = id2nameDict[item[0]] ccount = item[1] link = userLink[user] #writer.writerow([item[0],id2nameDict[item[0]],item[1]]) writer.writerow([id, user, ccount, link]) print("[+]Top users saved!") print("[+]Drawing graph...") #snap.DrawGViz(G, snap.gvlSfdp, "network---"+str(limit)+".png", "graph 3", True,NIdColorH) snap.DrawGViz(G, snap.gvlSfdp, "network-fan.png", "follow", True, NIdColorH) print("[+]Done!") ''' G1 = snap.TUNGraph.New() G1.AddNode(1) G1.AddNode(2) G1.AddNode(5) G1.AddEdge(2, 5) G1.AddEdge(1,5) snap.DrawGViz(G1, snap.gvlSfdp, "network.png", "graph 3", True) '''
### find max flow values ### max_impact = max_exploitability = 0 for target in targets: max_impact += nx.maximum_flow_value(ImpactGraph, "Non-CVE info: Router", target) try: min_cost = nx.max_flow_min_cost(ExploitabilityGraph, "Non-CVE info: Router", target) print("Min cost flow, "+target+": ",min_cost) except: print("Min cost flow, "+target+": no path") print("Max Impact: ",max_impact) print ("Time: " + str(time.time()-timestamp)) ### save ### snap.DrawGViz(home_network, snap.gvlDot, "deliverables/home_network.png", "Home Network", network_labels) schematic_dotfile = open("deliverables/schematic_circuit.dot", "w") schematic_dotfile.write(schematic_dotstr) schematic_dotfile.close() impact_dotfile = open("deliverables/impact_circuit.dot", "w") impact_dotfile.write(impact_dotstr) impact_dotfile.close() exploitability_dotfile = open("deliverables/exploitability_circuit.dot", "w") exploitability_dotfile.write(exploitability_dotstr) exploitability_dotfile.close() ### draw ### (schematic_graph,) = pydot.graph_from_dot_file('deliverables/schematic_circuit.dot') schematic_graph.write_png('deliverables/schematic_circuit.png') (impact_graph,) = pydot.graph_from_dot_file('deliverables/impact_circuit.dot')
('aww', 'news'): 21564, ('news', 'AskReddit'): 67337, ('news', 'funny'): 38013, ('news', 'pics'): 43798, ('news', 'gaming'): 32175, ('news', 'worldnews'): 52035, ('news', 'gifs'): 30334, ('news', 'todayilearned'): 35783, ('news', 'politics'): 33827, ('news', 'aww'): 21564, ('news', 'news'): 0} indicies = {} labels = snap.TIntStrH() counter = 0 if __name__=="__main__": G = snap.TUNGraph.New() for (sub0, sub1), val in data.items(): if (sub0 not in indicies): G.AddNode(counter) labels[counter] = sub0 indicies[sub0] = counter counter += 1 if (sub1 not in indicies): G.AddNode(counter) labels[counter] = sub1 indicies[sub1] = counter counter += 1 if (not G.IsEdge(indicies[sub0], indicies[sub1])): G.AddEdge(indicies[sub0], indicies[sub1]) snap.DrawGViz(G, snap.gvlNeato, "output.png", " top 10 subreddits ", labels)
import snap # Load network from text file. Network = snap.LoadEdgeList(snap.PNEANet, "karate.txt", 0, 1) # Print number of nodes and edges in network. print("Number of nodes in the network: {}".format(Network.GetNodes())) print("Number of edges in the network: {}".format(Network.GetEdges())) # Save network visualization. snap.DrawGViz(Network, snap.gvlNeato, "graph.png", "Zachary's karate club", True)
# Stanford Network Analysis Package ```{note} For some reasons, I can't have the snap module properly imported on mac. So, currently this notebook only runs on Google Colab. ``` !pip install snap-stanford import snap from IPython.display import Image Graph = snap.GenRndGnm(snap.PNGraph, 10, 20) snap.DrawGViz(Graph, snap.gvlDot, "graph.png", "graph 1") Image('graph.png') UGraph = snap.GenRndGnm(snap.PUNGraph, 10, 40) snap.DrawGViz(UGraph, snap.gvlNeato, "graph_undirected.png", "graph 2", True) Image('graph_undirected.png') NIdColorH = snap.TIntStrH() NIdColorH[0] = "green" NIdColorH[1] = "red" NIdColorH[2] = "purple" NIdColorH[3] = "blue" NIdColorH[4] = "yellow" Network = snap.GenRndGnm(snap.PNEANet, 5, 10) snap.DrawGViz(Network, snap.gvlSfdp, "network.png", "graph 3", True, NIdColorH)
import snap G = snap.GenGrid(snap.PUNGraph, 5, 3) snap.DrawGViz(G, snap.gvlDot, "grid5x3.png", "Grid 5x3")
# ---------------------------------- # Graph Testing # ---------------------------------- import snap as s import random as rand # Generate undirected Erdos Reyni random graph # set up vertices and edges vertices = 20 edges = 15 u_rndm_graph = snap.GenRndGnm(snap.PUNGraph, vertices, edges) # Draw the graph to a plot, counting vertices snap.DrawGViz(u_rndm_graph, snap.gvlNeato, "graph_rdm_undirected.png", "Undirected Random Graph", True) # Plot the out degree distrib snap.PlotOutDegDistr(u_rndm_graph, "graph_rdm_undirected", "Undirected graph - out-degree Distribution") # Compute and print the list of all edges for vertex_in in u_rndm_graph.Nodes(): for vertex_out_id in vertex_in.GetOutEdges(): print "edge (%d %d)" % (vertex_in.GetId(), vertex_out_id) # Save it to an external file snap.SaveEdgeList(u_rndm_graph, "Rndm_graph.txt", "Save as tab-separated list of edges") # Compute degree distribution and save it to an external textfile degree_vertex_count = snap.TIntPrV() s.GetOutDegCnt(u_rndm_graph, degree_vertex_count)
fout.write(domain_mapping[len(domain_mapping) - 1]) fout.close print "Graph model and mapping has been saved !" if not os.path.exists('./centrality_result'): os.makedirs('./centrality_result') print "domain mapping length = %d" % (len(domain_mapping)) print "nodes = %d" % (g1.GetNodes()) # calculating node centrality and save it as csv with open('./centrality_result/deg_centrality.csv', 'wb') as csvfile: q = Q.PriorityQueue() for NI in g1.Nodes(): #print "id = %d" % (NI.GetId()) q.put((-NI.GetInDeg(), domain_mapping[NI.GetId()])) writer = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) while not q.empty(): tup = q.get() newtup = (tup[0] * -100) / (g1.GetEdges() - 1), tup[1] writer.writerow(newtup) print "node centrality saved successfully !" print "Plotting the graph...." snap.DrawGViz(g1, snap.gvlDot, "g1.png", "g1", False)
import snap Graph = snap.GenRndGnm(snap.PNGraph, 100, 1000) snap.PlotShortPathDistr(Graph, "example", "Directed graph - shortest path") snap.DrawGViz(Graph, snap.gvlDot, "graph.png", "graph 1") UGraph = snap.GenRndGnm(snap.PUNGraph, 100, 1000) snap.PlotShortPathDistr(UGraph, "example", "Undirected graph - shortest path") snap.DrawGViz(UGraph, snap.gvlNeato, "graph_undirected.png", "graph 2", True) Network = snap.GenRndGnm(snap.PNEANet, 100, 1000) snap.PlotShortPathDistr(Network, "example", "Network - shortest path")
for item in b: if item not in proxy: proxy[item]=count rev_proxy[count]=item count=count+1 if b[item] not in proxy: proxy[b[item]]=count rev_proxy[count]=b[item] count=count+1 for item in proxy: n1.AddNode(proxy[item]) for item in b: if b[item] != 0: n1.AddEdge(proxy[b[item]],proxy[item]) NIdColorH = snap.TIntStrH() OutDegV = snap.TIntPrV() snap.GetNodeOutDegV(n1, OutDegV) for item in OutDegV: if item.GetVal2()>=3: NIdColorH[item.GetVal1()]="green" print rev_proxy[item.GetVal1()], item.GetVal2() if item.GetVal2()==0: NIdColorH[item.GetVal1()]="black" snap.DrawGViz(n1, snap.gvlDot, "graph3.png", "graph 1",False,NIdColorH) snap.DrawGViz(n1, snap.gvlNeato, "graph1.png", "graph 1",False,NIdColorH) snap.DrawGViz(n1, snap.gvlCirco, "graph2.png", "graph 2",False,NIdColorH)
norm = np.linalg.norm(final_graph) final_graph /= np.max(final_graph) generated = snap.TUNGraph.New() for i in range(len(final_graph)): generated.AddNode(i) # for i in range(len(final_graph)): # for j in range(i, len(final_graph)): # # rand = random.uniform(0, np.max(final_graph)) # rand = random.random() # if final_graph[i][j] < rand: # generated.AddEdge(i, j) edges = 0 while edges < G.GetEdges(): a = random.randint(0, G.GetNodes() - 1) b = random.randint(0, G.GetNodes() - 1) if a != b: rand = random.random() if final_graph[a][b] < rand: generated.AddEdge(a, b) edges += 1 snap.DrawGViz(generated, snap.gvlNeato, "attempt" + str(count) + ".png", "f**k", False) # snap.DrawGViz(G, snap.gvlNeato, "target.png", "target", False) print("Target Graph Edges: ", G.GetEdges()) print("Generated Graph Edges: ", generated.GetEdges()) snap.SaveEdgeList(generated, "attempt" + str(count) + '.txt')