code: def _edges2conns(G, edge_data=False):
      
      cm = {}
      for n in G.nodes(data=True):
          if edge_data:
              cm[n[1]['addr']] = [(G.node[nb]['addr'], G[n[0]][nb])
                                  for nb in G[n[0]]]
          else:
              cm[n[1]['addr']] = [(G.node[nb]['addr'], {}) for nb in G[n[0]]]
      return cm
docs: Create a mapping from graph edges to agent connections to be created.
  
      :param G:
          NetworkX's Graph or DiGraph which has :attr:`addr` attribute for each
          node.
  
      :param bool edge_data:
          If ``True``, stores also edge data to the returned dictionary.
  
      :returns:
          A dictionary where keys are agent addresses and values are lists of
          addresses to which key-agent should create connections in order to
          recreate the graph structure in an agent society.
  
      :rtype: dict