code: def _to_edge_list(self, G):
  		
  		node2id = dict(zip(G.nodes, range(len(G.nodes))))
  		id2node= dict((v,k) for k,v in node2id.items())
  	
  		nx.relabel_nodes(G, node2id,False)
  		edges = G.edges(data="weight")	
  	
  		node_pairs = np.array([ [edge[0], edge[1]] for edge in edges ]).astype(int)
  		w = np.array([ edge[2] for edge in edges ]).astype(float)
  	
  		if all(np.isnan(w)):
  			nx.set_edge_attributes(G, values =1, name='weight')
  			w[:] = 1.0
  		
  		nx.relabel_nodes(G,id2node,False)
  	
  		return node_pairs, w, node2id, id2node
docs: Transform NetworkX object to an edge list. 
  		
  		Parameters
  		----------
  		G : Graph object. 
  		
  		
  		Returns
  		-------
  		node_pairs : (M, 2) numpy array, where M is the number of edges. node_pairs[i,0] and node_pairs[i,1] are the endpoints of the ith edge.  
  		w : Mx1 numpy array. w[i] is the weight of the ith edge. 
  		node2id : Dict. A function mapping from node name to node id, i.e., node2id[node_name] gives the id.    
  		id2node : Dict. A function mapping from node id to node name, i.e., id2node[node_id] gives the node name.