class_docstr: This class provides a very high level route plan.
class_docstr_tok: ["This","class","provides","a","very","high","level","route","plan","."]
docstr: This method finds road segments that have an unconnected end, and
  adds them to the internal graph representation
docstr_tok: ["This","method","finds","road","segments","that","have","an","unconnected","end",",","and","adds","them","to","the","internal","graph","representation"]
code: def _find_loose_ends(self):
      """
      This method finds road segments that have an unconnected end, and
      adds them to the internal graph representation
      """
      count_loose_ends = 0
      hop_resolution = self._sampling_resolution
      for segment in self._topology:
          end_wp = segment["exit"]
          exit_xyz = segment["exitxyz"]
          road_id, section_id, lane_id = (
              end_wp.road_id,
              end_wp.section_id,
              end_wp.lane_id,
          )
          if (
              road_id in self._road_id_to_edge
              and section_id in self._road_id_to_edge[road_id]
              and lane_id in self._road_id_to_edge[road_id][section_id]
          ):
              pass
          else:
              count_loose_ends += 1
              if road_id not in self._road_id_to_edge:
                  self._road_id_to_edge[road_id] = dict()
              if section_id not in self._road_id_to_edge[road_id]:
                  self._road_id_to_edge[road_id][section_id] = dict()
              n1 = self._id_map[exit_xyz]
              n2 = -1 * count_loose_ends
              self._road_id_to_edge[road_id][section_id][lane_id] = (
                  n1,
                  n2,
              )
              next_wp = end_wp.next(hop_resolution)
              path = []
              while (
                  next_wp is not None
                  and next_wp
                  and next_wp[0].road_id == road_id
                  and next_wp[0].section_id == section_id
                  and next_wp[0].lane_id == lane_id
              ):
                  path.append(next_wp[0])
                  next_wp = next_wp[0].next(hop_resolution)
              if path:
                  n2_xyz = (
                      path[-1].transform.location.x,
                      path[-1].transform.location.y,
                      path[-1].transform.location.z,
                  )
                  self._graph.add_node(n2, vertex=n2_xyz)
                  self._graph.add_edge(
                      n1,
                      n2,
                      length=len(path) + 1,
                      path=path,
                      entry_waypoint=end_wp,
                      exit_waypoint=path[-1],
                      entry_vector=None,
                      exit_vector=None,
                      net_vector=None,
                      intersection=end_wp.is_junction,
                      type=RoadOption.LANEFOLLOW,
                  )
  
file_path: carla/PythonAPI/carla/agents/navigation/global_route_planner.py
imports: import math
  import numpy
  import networkx
  import carla
  from agents.navigation.local_planner import RoadOption
  from agents.tools.misc import vector
label_desc: Use image node_id 5 for calling the GlobalRoutePlanner obj's underlying member method code with example usage: obj._find_loose_ends() without return types