Anduril autonomous vehicles exchange peer-to-peer status through an undirected network of vehicle links. Given all vehicle identifiers and active links, determine whether any cycle exists and return every connected component, including isolated vehicles.
Implement analyze_vehicle_network(vehicles, links).
vehicles is a list of unique strings.links is a list of two-element lists, where each pair [u, v] represents an undirected link between vehicles u and v.links appears in vehicles, and self-links are not present.has_cycle: a boolean that is True if any component contains an undirected cycle.components: a list of component objects. Each object has vehicles, a lexicographically sorted list of identifiers, and has_cycle, indicating whether that component contains a cycle.components by the first vehicle identifier in each component. Do not mutate the inputs.A cycle exists when an edge connects two vehicles that are already connected by previously processed edges. Duplicate links are considered separate edges, so two identical links form a cycle under the standard undirected multigraph definition.
def analyze_vehicle_network(vehicles, links):