code: def calc_geo_dist_matrix_vincenty(nodes_pos):
      
  
      branch_detour_factor = cfg_ding0.get('assumptions', 'branch_detour_factor')
  
      matrix = {}
  
      for i in nodes_pos:
          pos_origin = tuple(nodes_pos[i])
  
          matrix[i] = {}
  
          for j in nodes_pos:
              pos_dest = tuple(nodes_pos[j])
              # notice: vincenty takes (lat,lon), thus the (x,y)/(lon,lat) tuple is reversed
              distance = branch_detour_factor * vincenty(tuple(reversed(pos_origin)), tuple(reversed(pos_dest))).km
              matrix[i][j] = distance
  
      return matrix
docs: Calculates the geodesic distance between all nodes in `nodes_pos` incorporating the detour factor in config_calc.cfg.
          
      For every two points/coord it uses geopy's vincenty function (formula devised by Thaddeus Vincenty, 
      with an accurate ellipsoidal model of the earth). As default ellipsoidal model of the earth WGS-84 is used.
      For more options see
      
      https://geopy.readthedocs.org/en/1.10.0/index.html?highlight=vincenty#geopy.distance.vincenty
  
      Parameters
      ----------
      nodes_pos: dict 
          dictionary of nodes with positions, with x=longitude, y=latitude, and the following format::
          
          {
              'node_1': (x_1, y_1), 
              ...,
              'node_n': (x_n, y_n)
          }
     
      Returns
      -------
      :obj:`dict`
          dictionary with distances between all nodes (in km), with the following format::
          
          {
              'node_1': {'node_1': dist_11, ..., 'node_n': dist_1n},
              ..., 
              'node_n': {'node_1': dist_n1, ..., 'node_n': dist_nn}
          }