code: def _bidirectional_pred_succ(
      G, source, target, ignore_nodes=None, ignore_edges=None
  ):
      """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 ignore_nodes and (
          source in ignore_nodes or target in ignore_nodes
      ):
          raise nx.NetworkXNoPath(
              f"No path between {source} and {target}."
          )
      if target == source:
          return ({target: None}, {source: None}, source)
  
      # handle either directed or undirected
      if G.is_directed():
          Gpred = G.predecessors
          Gsucc = G.successors
      else:
          Gpred = G.neighbors
          Gsucc = G.neighbors
  
      # support optional nodes filter
      if ignore_nodes:
  
          def filter_iter(nodes):
              def iterate(v):
                  for w in nodes(v):
                      if w not in ignore_nodes:
                          yield w
  
              return iterate
  
          Gpred = filter_iter(Gpred)
          Gsucc = filter_iter(Gsucc)
  
      # support optional edges filter
      if ignore_edges:
          if G.is_directed():
  
              def filter_pred_iter(pred_iter):
                  def iterate(v):
                      for w in pred_iter(v):
                          if (w, v) not in ignore_edges:
                              yield w
  
                  return iterate
  
              def filter_succ_iter(succ_iter):
                  def iterate(v):
                      for w in succ_iter(v):
                          if (v, w) not in ignore_edges:
                              yield w
  
                  return iterate
  
              Gpred = filter_pred_iter(Gpred)
              Gsucc = filter_succ_iter(Gsucc)
  
          else:
  
              def filter_iter(nodes):
                  def iterate(v):
                      for w in nodes(v):
                          if (v, w) not in ignore_edges and (
                              w,
                              v,
                          ) not in ignore_edges:
                              yield w
  
                  return iterate
  
              Gpred = filter_iter(Gpred)
              Gsucc = filter_iter(Gsucc)
  
      # 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:
                          # found path
                          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/simple_paths.py
imports: from heapq import heappop, heappush
  from itertools import count
  import networkx
  from networkx.algorithms.shortest_paths.weighted import _weight_function
  from networkx.utils import not_implemented_for, pairwise
label_desc: Use image node_id 7 for calling a global function with example usage: _bidirectional_pred_succ(G, source, target, ignore_nodes, ignore_edges) and returns: dict,  dict,  source, iterate, iterate, iterate, iterate, pred,  succ,  w, pred,  succ,  w