code: def build_topology(sumo_net):
      """
      Builds sumo topology.
      """
      # --------------------------
      # OpenDrive->Sumo mapped ids
      # --------------------------
      # Only takes into account standard roads.
      #
      #   odr2sumo_ids = {(odr_road_id, odr_lane_id) : [(sumo_edge_id, sumo_lane_index), ...], ...}
      odr2sumo_ids = {}
      for edge in sumo_net.getEdges():
          for lane in edge.getLanes():
              if lane.getParam("origId") is None:
                  raise RuntimeError(
                      'Sumo lane {} does not have "origId" parameter. Make sure that the --output.original-names parameter is active when running netconvert.'.format(
                          lane.getID()
                      )
                  )
  
              if len(lane.getParam("origId").split()) > 1:
                  logging.warning(
                      "[Building topology] Sumo net contains joined opendrive roads."
                  )
  
              for odr_id in lane.getParam("origId").split():
                  odr_road_id, odr_lane_id = odr_id.split("_")
                  if (
                      odr_road_id,
                      int(odr_lane_id),
                  ) not in odr2sumo_ids:
                      odr2sumo_ids[
                          (odr_road_id, int(odr_lane_id))
                      ] = set()
                  odr2sumo_ids[(odr_road_id, int(odr_lane_id))].add(
                      (edge.getID(), lane.getIndex())
                  )
  
      # -----------
      # Connections
      # -----------
      #
      #   topology -- {(sumo_road_id, sumo_lane_index): [(sumo_road_id, sumo_lane_index), ...], ...}
      #   paths    -- {(odr_road_id, odr_lane_id): [
      #                   ((sumo_edge_id, sumo_lane_index), (sumo_edge_id, sumo_lane_index))
      #               ]}
      topology = {}
      paths = {}
  
      for from_edge in sumo_net.getEdges():
          for to_edge in sumo_net.getEdges():
              connections = from_edge.getConnections(to_edge)
              for connection in connections:
                  from_ = connection.getFromLane()
                  to_ = connection.getToLane()
                  from_edge_id, from_lane_index = (
                      from_.getEdge().getID(),
                      from_.getIndex(),
                  )
                  to_edge_id, to_lane_index = (
                      to_.getEdge().getID(),
                      to_.getIndex(),
                  )
  
                  if (from_edge_id, from_lane_index) not in topology:
                      topology[(from_edge_id, from_lane_index)] = set()
  
                  topology[(from_edge_id, from_lane_index)].add(
                      (to_edge_id, to_lane_index)
                  )
  
                  # Checking if the connection is an opendrive path.
                  conn_odr_ids = connection.getParam("origId")
                  if conn_odr_ids is not None:
                      if len(conn_odr_ids.split()) > 1:
                          logging.warning(
                              "[Building topology] Sumo net contains joined opendrive paths."
                          )
  
                      for odr_id in conn_odr_ids.split():
                          odr_road_id, odr_lane_id = odr_id.split("_")
                          if (
                              odr_road_id,
                              int(odr_lane_id),
                          ) not in paths:
                              paths[
                                  (odr_road_id, int(odr_lane_id))
                              ] = set()
  
                          paths[(odr_road_id, int(odr_lane_id))].add(
                              (
                                  (from_edge_id, from_lane_index),
                                  (to_edge_id, to_lane_index),
                              )
                          )
  
      return SumoTopology(topology, paths, odr2sumo_ids)
  
imports: import argparse
  import bisect
  import collections
  import logging
  import shutil
  import subprocess
  import tempfile
  import lxml.etree
  import glob
  import os
  import sys
  import carla
  import sumolib
label_desc: Use image node_id 1 for calling a global function with example usage: build_topology(sumo_net) and returns: SumoTopology