class_docstr: Breadth First Walk that generates a sampled number of paths from a starting node.
  It can be used to extract a random sub-graph starting from a set of initial nodes from Neo4j database.
docstr: Send queries to Neo4j databases and collect sampled breadth-first walks starting from the root nodes.
  
  Args:
      nodes (list of hashable): A list of root node ids such that from each node n BFWs will
          be generated up to the given depth d.
      n (int): Number of walks per node id.
      in_size (list of int): The number of in-directed nodes to sample with replacement at each depth of the walk.
      out_size (list of int): The number of out-directed nodes to sample with replacement at each depth of the walk.
  Returns:
      A list of multi-hop neighbourhood samples. Each sample expresses a collection of nodes, which could be either in-neighbors,
      or out-neighbors of the previous hops.
      Result has the format:
      [[head1, head2, ...],
      [in1_head1, in2_head1, ..., in1_head2, in2_head2, ...], [out1_head1, out2_head1, ..., out1_head2, out2_head2, ...],
      [in1_in1_head1, in2_in1_head1, ..., in1_in2_head1, ...], [out1_in1_head1, out2_in1_head1, ..., out1_in2_head1, ...],
      [in1_out1_head1, in2_out1_head1, ..., in1_out2_head1, ...], [out1_out1_head1, out2_out1_head1, ..., out1_out2_head1, ...],
      ...
      ]
docstr_tok: ["Send","queries","to","Neo4j","databases","and","collect","sampled","breadth-first","walks","starting","from","the","root","nodes",".","Args",":","nodes","(","list","of","hashable",")",":","A","list","of","root","node","ids","such","that","from","each","node","n","BFWs","will","be","generated","up","to","the","given","depth","d.","n","(","int",")",":","Number","of","walks","per","node","id",".","in_size","(","list","of","int",")",":","The","number","of","in-directed","nodes","to","sample","with","replacement","at","each","depth","of","the","walk",".","out_size","(","list","of","int",")",":","The","number","of","out-directed","nodes","to","sample","with","replacement","at","each","depth","of","the","walk",".","Returns",":","A","list","of","multi-hop","neighbourhood","samples",".","Each","sample","expresses","a","collection","of","nodes",",","which","could","be","either","in-neighbors",",","or","out-neighbors","of","the","previous","hops",".","Result","has","the","format",":","[","[","head1",",","head2",",","...","]",",","[","in1_head1",",","in2_head1",",","...",",","in1_head2",",","in2_head2",",","...","]",",","[","out1_head1",",","out2_head1",",","...",",","out1_head2",",","out2_head2",",","...","]",",","[","in1_in1_head1",",","in2_in1_head1",",","...",",","in1_in2_head1",",","...","]",",","[","out1_in1_head1",",","out2_in1_head1",",","...",",","out1_in2_head1",",","...","]",",","[","in1_out1_head1",",","in2_out1_head1",",","...",",","in1_out2_head1",",","...","]",",","[","out1_out1_head1",",","out2_out1_head1",",","...",",","out1_out2_head1",",","...","]",",","...","]"]
code: def run(self, nodes=None, n=1, in_size=None, out_size=None):
      """
      Send queries to Neo4j databases and collect sampled breadth-first walks starting from the root nodes.
  
      Args:
          nodes (list of hashable): A list of root node ids such that from each node n BFWs will
              be generated up to the given depth d.
          n (int): Number of walks per node id.
          in_size (list of int): The number of in-directed nodes to sample with replacement at each depth of the walk.
          out_size (list of int): The number of out-directed nodes to sample with replacement at each depth of the walk.
      Returns:
          A list of multi-hop neighbourhood samples. Each sample expresses a collection of nodes, which could be either in-neighbors,
          or out-neighbors of the previous hops.
          Result has the format:
          [[head1, head2, ...],
          [in1_head1, in2_head1, ..., in1_head2, in2_head2, ...], [out1_head1, out2_head1, ..., out1_head2, out2_head2, ...],
          [in1_in1_head1, in2_in1_head1, ..., in1_in2_head1, ...], [out1_in1_head1, out2_in1_head1, ..., out1_in2_head1, ...],
          [in1_out1_head1, in2_out1_head1, ..., in1_out2_head1, ...], [out1_out1_head1, out2_out1_head1, ..., out1_out2_head1, ...],
          ...
          ]
      """
      # FIXME: we may want to run validation on all the run parameters similar to other GraphWalk classes
  
      head_nodes = [head_node for head_node in nodes for _ in range(n)]
      hops = [[head_nodes]]
  
      in_sample_query = _bfs_neighbor_query(
          sampling_direction="IN",
          id_property=self.graph.cypher_id_property,
          node_label=self.graph.cypher_node_label,
      )
      out_sample_query = _bfs_neighbor_query(
          sampling_direction="OUT",
          id_property=self.graph.cypher_id_property,
          node_label=self.graph.cypher_node_label,
      )
  
      # this sends O(2^number of hops) queries to the database, because the code is cleanest like that
      for in_num, out_num in zip(in_size, out_size):
          last_hop = hops[-1]
          this_hop = []
          for cur_nodes in last_hop:
              # get in-neighbor nodes
              neighbor_records = self.graph.graph_db.run(
                  in_sample_query,
                  parameters={
                      "node_id_list": cur_nodes,
                      "num_samples": in_num,
                  },
              )
              this_hop.append(
                  neighbor_records.data()[0]["next_samples"]
              )
  
              # get out-neighbor nodes
              neighbor_records = self.graph.graph_db.run(
                  out_sample_query,
                  parameters={
                      "node_id_list": cur_nodes,
                      "num_samples": out_num,
                  },
              )
              this_hop.append(
                  neighbor_records.data()[0]["next_samples"]
              )
  
          hops.append(this_hop)
  
      return sum(hops, [])
  
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 2 for calling the Neo4jDirectedBreadthFirstNeighbors obj's underlying member method code with example usage: obj.run(nodes, n, in_size, out_size) and returns: sum