code: def listlist_and_matrix_to_listdict(graph, weight=None):
      
      if weight:
          return [{v:weight[u][v] for v in graph[u]} for u in range(len(graph))]
      else:
          return [{v:None for v in graph[u]} for u in range(len(graph))]
docs: Transforms the weighted adjacency list representation of a graph
      of type listlist + optional weight matrix
      into the listdict representation
  
      :param graph: in listlist representation
      :param weight: optional weight matrix
      :returns: graph in listdict representation
      :complexity: linear