code: def read_edgelist(self, filename, weighted=False, directed=False):
      self.G = nx.DiGraph()
  
      if directed:
  
          def read_unweighted(l):
              src, dst = l.split()
              self.G.add_edge(src, dst)
              self.G[src][dst]["weight"] = 1.0
  
          def read_weighted(l):
              src, dst, w = l.split()
              self.G.add_edge(src, dst)
              self.G[src][dst]["weight"] = float(w)
  
      else:
  
          def read_unweighted(l):
              src, dst = l.split()
              self.G.add_edge(src, dst)
              self.G.add_edge(dst, src)
              self.G[src][dst]["weight"] = 1.0
              self.G[dst][src]["weight"] = 1.0
  
          def read_weighted(l):
              src, dst, w = l.split()
              self.G.add_edge(src, dst)
              self.G.add_edge(dst, src)
              self.G[src][dst]["weight"] = float(w)
              self.G[dst][src]["weight"] = float(w)
  
      fin = open(filename, "r")
      func = read_unweighted
      if weighted:
          func = read_weighted
      while 1:
          l = fin.readline()
          if l == "":
              break
          func(l)
      fin.close()
      self.encode_node()
  
file_path: OpenNE/src/openne/graph.py
imports: import networkx
  import pickle
  import numpy
  import scipy.sparse
label_desc: Use image node_id 5 for calling the Graph obj's underlying member method code with example usage: obj.read_edgelist(filename, weighted, directed) without return types