code: def _bidirectional_pred_succ(G, source, target):
      """Bidirectional shortest path helper.
  
      Returns (pred, succ, w) where
      pred is a dictionary of predecessors from w to the source, and
      succ is a dictionary of successors from w to the target.
      """
      # does BFS from both source and target and meets in the middle
      if target == source:
          return ({target: None}, {source: None}, source)
  
      # handle either directed or undirected
      if G.is_directed():
          Gpred = G.pred
          Gsucc = G.succ
      else:
          Gpred = G.adj
          Gsucc = G.adj
  
      # predecessor and successors in search
      pred = {source: None}
      succ = {target: None}
  
      # initialize fringes, start with forward
      forward_fringe = [source]
      reverse_fringe = [target]
  
      while forward_fringe and reverse_fringe:
          if len(forward_fringe) <= len(reverse_fringe):
              this_level = forward_fringe
              forward_fringe = []
              for v in this_level:
                  for w in Gsucc[v]:
                      if w not in pred:
                          forward_fringe.append(w)
                          pred[w] = v
                      if w in succ:  # path found
                          return pred, succ, w
          else:
              this_level = reverse_fringe
              reverse_fringe = []
              for v in this_level:
                  for w in Gpred[v]:
                      if w not in succ:
                          succ[w] = v
                          reverse_fringe.append(w)
                      if w in pred:  # found path
                          return pred, succ, w
  
      raise nx.NetworkXNoPath(f"No path between {source} and {target}.")
  
file_path: networkx/networkx/algorithms/shortest_paths/unweighted.py
imports: import warnings
  import networkx
label_desc: Use image node_id 6 for calling a global function with example usage: _bidirectional_pred_succ(G, source, target) and returns: dict,  dict,  source, pred,  succ,  w, pred,  succ,  w