Generation

time complexitySat, 03 Dec 2022

from typing import List, Tuple def generate_graph(schedules:List[List[List[int]]]) -> List[List[Tuple[int, int, float]]]: graphAdjacencyList = [] tmpEdgeList = [] tmpTuple = () for i in range(len(schedules)): for j in range(len(schedules[i])): for k in range(len(schedules[i][j])): if schedules[i][j][k] != float('inf'): tmpTuple = j, k, k + schedules[i][j][k] tmpEdgeList.append(tmpTuple) if len(tmpEdgeList) > 0: graphAdjacencyList.append(tmpEdgeList) tmpEdgeList = [] return graphAdjacencyList

O(N)

Questions about programming?Chat with your personal AI assistant