nodes: 0, module; 1, function_definition; 2, function_name:__sort_adjacency_lists; 3, parameters; 4, block; 5, identifier:dfs_data; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, return_statement; 13, comment:"""Sorts the adjacency list representation by the edge weights."""; 14, assignment; 15, assignment; 16, assignment; 17, assignment; 18, pattern_list; 19, call; 20, block; 21, identifier:new_adjacency_lists; 22, identifier:new_adjacency_lists; 23, dictionary; 24, identifier:adjacency_lists; 25, subscript; 26, identifier:edge_weights; 27, subscript; 28, identifier:edge_lookup; 29, subscript; 30, identifier:node_id; 31, identifier:adj_list; 32, identifier:list; 33, argument_list; 34, expression_statement; 35, expression_statement; 36, for_statement; 37, comment:# Fronds should be before branches if the weights are equal; 38, expression_statement; 39, comment:# Sort by weights; 40, expression_statement; 41, comment:# Add the new sorted list to the new adjacency list lookup table; 42, expression_statement; 43, identifier:dfs_data; 44, string; 45, identifier:dfs_data; 46, string; 47, identifier:dfs_data; 48, string; 49, call; 50, assignment; 51, assignment; 52, identifier:node_b; 53, identifier:adj_list; 54, block; 55, assignment; 56, call; 57, assignment; 58, string_content:adj; 59, string_content:edge_weights; 60, string_content:edge_lookup; 61, attribute; 62, argument_list; 63, identifier:node_weight_lookup; 64, dictionary; 65, identifier:frond_lookup; 66, dictionary; 67, expression_statement; 68, expression_statement; 69, expression_statement; 70, identifier:new_list; 71, call; 72, attribute; 73, argument_list; 74, subscript; 75, identifier:new_list; 76, identifier:adjacency_lists; 77, identifier:items; 78, assignment; 79, assignment; 80, assignment; 81, identifier:sorted; 82, argument_list; 83, identifier:new_list; 84, identifier:sort; 85, keyword_argument; 86, identifier:new_adjacency_lists; 87, identifier:node_id; 88, identifier:edge_id; 89, call; 90, subscript; 91, subscript; 92, subscript; 93, conditional_expression:1 if edge_lookup[edge_id] == 'backedge' else 2; 94, identifier:adj_list; 95, keyword_argument; 96, identifier:key; 97, lambda; 98, attribute; 99, argument_list; 100, identifier:node_weight_lookup; 101, identifier:node_b; 102, identifier:edge_weights; 103, identifier:edge_id; 104, identifier:frond_lookup; 105, identifier:node_b; 106, integer:1; 107, comparison_operator:edge_lookup[edge_id] == 'backedge'; 108, integer:2; 109, identifier:key; 110, lambda; 111, lambda_parameters; 112, subscript; 113, subscript; 114, identifier:get_first_edge_id_by_node_ids; 115, identifier:node_id; 116, identifier:node_b; 117, subscript; 118, string; 119, lambda_parameters; 120, subscript; 121, identifier:n; 122, identifier:node_weight_lookup; 123, identifier:n; 124, identifier:dfs_data; 125, string; 126, identifier:edge_lookup; 127, identifier:edge_id; 128, string_content:backedge; 129, identifier:n; 130, identifier:frond_lookup; 131, identifier:n; 132, string_content:graph
code: def __sort_adjacency_lists(dfs_data):
      """Sorts the adjacency list representation by the edge weights."""
      new_adjacency_lists = {}
  
      adjacency_lists = dfs_data['adj']
      edge_weights = dfs_data['edge_weights']
      edge_lookup = dfs_data['edge_lookup']
  
      for node_id, adj_list in list(adjacency_lists.items()):
          node_weight_lookup = {}
          frond_lookup = {}
          for node_b in adj_list:
              edge_id = dfs_data['graph'].get_first_edge_id_by_node_ids(node_id, node_b)
              node_weight_lookup[node_b] = edge_weights[edge_id]
              frond_lookup[node_b] = 1 if edge_lookup[edge_id] == 'backedge' else 2
  
          # Fronds should be before branches if the weights are equal
          new_list = sorted(adj_list, key=lambda n: frond_lookup[n])
  
          # Sort by weights
          new_list.sort(key=lambda n: node_weight_lookup[n])
  
          # Add the new sorted list to the new adjacency list lookup table
          new_adjacency_lists[node_id] = new_list
  
      return new_adjacency_lists