code: def _bfs_neighbor_query(
      sampling_direction, id_property, node_label=None
  ):
      """
      Generate the Cypher neighbor sampling query for a batch of nodes.
  
      Args:
          sampling_direction (String): indicate type of neighbors needed to sample. Direction must be 'in', 'out' or 'both'.
          id_property (str): Cypher-escaped property name for node IDs.
          node_label (str, optional): Common label for all nodes in the graph, if such label exists.
              Providing this is useful if there are any indexes created on this label (e.g. on node IDs),
              as it will improve performance of queries.
      Returns:
          The cypher query that samples the neighbor ids for a batch of nodes.
      """
      direction_arrow = {"BOTH": "--", "IN": "<--", "OUT": "-->"}[
          sampling_direction
      ]
      match_cur_node = (
          "MATCH(cur_node)"
          if node_label is None
          else f"MATCH(cur_node:{node_label})"
      )
  
      return f"""
          // expand the list of node id in seperate rows of ids.
          UNWIND $node_id_list AS node_id
  
          // for each node id in every row, collect the random list of its neighbors.
          CALL apoc.cypher.run(
  
              '{match_cur_node} WHERE cur_node.{id_property} = $node_id
  
              // find the neighbors
              MATCH (cur_node){direction_arrow}(neighbors)
  
              // collect neighbors in a list
              WITH CASE collect(neighbors) WHEN [] THEN [null] ELSE collect(neighbors) END AS in_neighbors_list
  
              // pick random nodes with replacement
              WITH apoc.coll.randomItems(in_neighbors_list, $num_samples, True) AS sampled
  
              // pull the ids of the sampled nodes only
              UNWIND sampled AS nn
              // collect ignores nulls, so re-handle the no-neighbours case to ensure we get [null, null, ...] output
              WITH CASE collect(nn.{id_property}) WHEN [] THEN sampled ELSE collect(nn.{id_property}) END AS in_samples_list
  
              RETURN in_samples_list',
              {{ node_id: node_id, num_samples: $num_samples  }}) YIELD value
  
          RETURN apoc.coll.flatten(collect(value.in_samples_list)) AS next_samples
          """
  
file_path: stellargraph/stellargraph/connector/neo4j/sampler.py
imports: from ...core.experimental import experimental
  from .graph import Neo4jStellarGraph, Neo4jStellarDiGraph
label_desc: Use image node_id 1 for calling a global function with example usage: _bfs_neighbor_query(sampling_direction, id_property, node_label) and returns: str, match_cur_node, str, id_property, str, direction_arrow, str, id_property, str, id_property, str