code: def all_shortest_paths(
      G, source, target, weight=None, method="dijkstra"
  ):
      """Compute all shortest simple paths in the graph.
  
      Parameters
      ----------
      G : NetworkX graph
  
      source : node
         Starting node for path.
  
      target : node
         Ending node for path.
  
      weight : None, string or function, optional (default = None)
          If None, every edge has weight/distance/cost 1.
          If a string, use this edge attribute as the edge weight.
          Any edge attribute not present defaults to 1.
          If this is a function, the weight of an edge is the value
          returned by the function. The function must accept exactly
          three positional arguments: the two endpoints of an edge and
          the dictionary of edge attributes for that edge.
          The function must return a number.
  
      method : string, optional (default = 'dijkstra')
         The algorithm to use to compute the path lengths.
         Supported options: 'dijkstra', 'bellman-ford'.
         Other inputs produce a ValueError.
         If `weight` is None, unweighted graph methods are used, and this
         suggestion is ignored.
  
      Returns
      -------
      paths : generator of lists
          A generator of all paths between source and target.
  
      Raises
      ------
      ValueError
          If `method` is not among the supported options.
  
      NetworkXNoPath
          If `target` cannot be reached from `source`.
  
      Examples
      --------
      >>> G = nx.Graph()
      >>> nx.add_path(G, [0, 1, 2])
      >>> nx.add_path(G, [0, 10, 2])
      >>> print([p for p in nx.all_shortest_paths(G, source=0, target=2)])
      [[0, 1, 2], [0, 10, 2]]
  
      Notes
      -----
      There may be many shortest paths between the source and target.  If G
      contains zero-weight cycles, this function will not produce all shortest
      paths because doing so would produce infinitely many paths of unbounded
      length -- instead, we only produce the shortest simple paths.
  
      See Also
      --------
      shortest_path
      single_source_shortest_path
      all_pairs_shortest_path
      """
      method = "unweighted" if weight is None else method
      if method == "unweighted":
          pred = nx.predecessor(G, source)
      elif method == "dijkstra":
          pred, dist = nx.dijkstra_predecessor_and_distance(
              G, source, weight=weight
          )
      elif method == "bellman-ford":
          pred, dist = nx.bellman_ford_predecessor_and_distance(
              G, source, weight=weight
          )
      else:
          raise ValueError(f"method not supported: {method}")
  
      return _build_paths_from_predecessors({source}, target, pred)
  
file_path: networkx/networkx/algorithms/shortest_paths/generic.py
imports: import warnings
  import networkx
label_desc: Use image node_id 5 for calling a global function with example usage: all_shortest_paths(G, source, target, weight, method) and returns: _build_paths_from_predecessors