





def 	UpperCamelCase__(       UpperCamelCase__			:       list[list[float]]  )->list[list[float]]:
       A__											=						[]
       for data in source_data:
              for i, el in enumerate(UpperCamelCase__  ):
                     if len(UpperCamelCase__  ) < i + 1:
                            data_lists.append([]  )
                     data_lists[i].append(float(UpperCamelCase__  )  )
       return data_lists


def 	UpperCamelCase__(       UpperCamelCase__			:       list[list[float]] ,     UpperCamelCase__			:       list[int]  )->list[list[float]]:
       A__											=						[]
       for dlist, weight in zip(UpperCamelCase__ ,     UpperCamelCase__  ):
              A__											=						min(UpperCamelCase__  )
              A__											=						max(UpperCamelCase__  )

              A__											=						[]
              # for weight 0 score is 1 - actual score
              if weight == 0:
                     for item in dlist:
                            try:
                                   score.append(1 - ((item - mind) / (maxd - mind))  )
                            except ZeroDivisionError:
                                   score.append(1  )

              elif weight == 1:
                     for item in dlist:
                            try:
                                   score.append((item - mind) / (maxd - mind)  )
                            except ZeroDivisionError:
                                   score.append(0  )

        # weight not 0 or 1
              else:
                     A__											=						f"Invalid weight of {weight:f} provided"
                     raise ValueError(UpperCamelCase__  )

              score_lists.append(UpperCamelCase__  )

       return score_lists


def 	UpperCamelCase__(       UpperCamelCase__			:       list[list[float]]  )->list[float]:
       A__											=						[0 for i in range(len(score_lists[0]  )  )]

       for slist in score_lists:
              for j, ele in enumerate(UpperCamelCase__  ):
                     A__											=						final_scores[j] + ele

       return final_scores


def 	UpperCamelCase__(       UpperCamelCase__			:       list[list[float]] ,     UpperCamelCase__			:       list[int]  )->list[list[float]]:
       A__											=						get_data(UpperCamelCase__  )
       A__											=						calculate_each_score(UpperCamelCase__ ,     UpperCamelCase__  )
       A__											=						generate_final_scores(UpperCamelCase__  )

       # append scores to source data
       for i, ele in enumerate(UpperCamelCase__  ):
              source_data[i].append(UpperCamelCase__  )

       return source_data












a__:      Dict									=		{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

a__:      str									=		{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]] ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       list[bool]  )->list[int]:
       A__											=						True
       A__											=						[]

       for neighbour in graph[vert]:
              if not visited[neighbour]:
                     order += topology_sort(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       order.append(UpperCamelCase__  )

       return order


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]] ,     UpperCamelCase__			:       int ,     UpperCamelCase__			:       list[bool]  )->list[int]:
       A__											=						True
       A__											=						[vert]

       for neighbour in reversed_graph[vert]:
              if not visited[neighbour]:
                     component += find_components(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       return component


def 	UpperCamelCase__(       UpperCamelCase__			:       dict[int, list[int]]  )->list[list[int]]:
       A__											=						len(UpperCamelCase__  ) * [False]
       A__											=						{vert: [] for vert in range(len(UpperCamelCase__  )  )}

       for vert, neighbours in graph.items():
              for neighbour in neighbours:
                     reversed_graph[neighbour].append(UpperCamelCase__  )

       A__											=						[]
       for i, was_visited in enumerate(UpperCamelCase__  ):
              if not was_visited:
                     order += topology_sort(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )

       A__											=						[]
       A__											=						len(UpperCamelCase__  ) * [False]

       for i in range(len(UpperCamelCase__  )  ):
              A__											=						order[len(UpperCamelCase__  ) - i - 1]
              if not visited[vert]:
                     A__											=						find_components(UpperCamelCase__ ,     UpperCamelCase__ ,     UpperCamelCase__  )
                     components_list.append(UpperCamelCase__  )

       return components_list





