code: def test_walk_generation_single_root_node(self):
      g = create_test_graph(self_loop=True)
      bfw = SampledHeterogeneousBreadthFirstWalk(g)
  
      def _conv(ns):
          return [
              -1 if n is None else g.node_ids_to_ilocs([n])[0]
              for n in ns
          ]
  
      nodes = _conv([3])
      n = 1
      n_size = [2]
  
      subgraphs = bfw.run(nodes=nodes, n=n, n_size=n_size, seed=42)
      assert len(subgraphs) == n
      valid_result = [[_conv([3]), _conv(["5", 1])]]
      assert _recursive_items_equal(subgraphs, valid_result)
  
      n_size = [3]
      subgraphs = bfw.run(nodes=nodes, n=n, n_size=n_size, seed=42)
      assert len(subgraphs) == n
      valid_result = [[_conv([3]), _conv(["5", 1, 1])]]
      assert _recursive_items_equal(subgraphs, valid_result)
  
      n_size = [1, 1]
      subgraphs = bfw.run(nodes=nodes, n=n, n_size=n_size, seed=42)
      assert len(subgraphs) == n
      valid_result = [
          [_conv([3]), _conv(["5"]), _conv([1]), _conv([3])]
      ]
      assert _recursive_items_equal(subgraphs, valid_result)
  
      nodes = _conv(["5"])
      n_size = [2, 3]
      subgraphs = bfw.run(nodes=nodes, n=n, n_size=n_size, seed=42)
      assert len(subgraphs) == n
      valid_result = [
          [
              ["5"],
              [4, 1],
              [3, 3],
              ["5", "5", "5"],
              [2, 2, 2],
              [4, "5", 4],
              [2, 3, 3],
              [1, "5", "5"],
              [1, "5", "5"],
          ]
      ]
      valid_result = [[_conv(x) for x in y] for y in valid_result]
      assert _recursive_items_equal(subgraphs, valid_result)
  
      nodes = _conv(["5"])
      n_size = [2, 3]
      n = 3
      subgraphs = bfw.run(nodes=nodes, n=n, n_size=n_size, seed=42)
      assert len(subgraphs) == n
      valid_result = [
          [
              ["5"],
              [4, 1],
              [3, 3],
              ["5", "5", "5"],
              [2, 2, 2],
              [4, "5", 4],
              [2, 3, 3],
              [1, "5", "5"],
              [1, "5", "5"],
          ],
          [
              ["5"],
              [1, 1],
              [6, 3],
              [4, 4, "5"],
              [3, 3, 3],
              ["5", "5", 4],
              [3, 3, 3],
              ["5", "5", "5"],
              [1, 1, 1],
          ],
          [
              ["5"],
              [1, 1],
              [3, 3],
              ["5", 4, 4],
              [2, 2, 3],
              ["5", "5", 4],
              [3, 2, 2],
              ["5", "5", "5"],
              ["5", "5", "5"],
          ],
      ]
      valid_result = [[_conv(x) for x in y] for y in valid_result]
  
      assert _recursive_items_equal(subgraphs, valid_result)
      #
      # Test with multi-graph
      #
      g = create_test_graph(multi=True)
      bfw = SampledHeterogeneousBreadthFirstWalk(g)
  
      nodes = _conv([1])
      n = 1
      n_size = [2]
  
      subgraphs = bfw.run(
          nodes=nodes, n=n, n_size=n_size, seed=19893839
      )
      assert len(subgraphs) == n
  
      valid_result = [[[1], [4, 4], [4, 4], [2, 2]]]
      valid_result = [[_conv(x) for x in y] for y in valid_result]
      _recursive_items_equal(subgraphs, valid_result)
  
      n_size = [2, 3]
      subgraphs = bfw.run(
          nodes=nodes, n=n, n_size=n_size, seed=19893839
      )
      assert len(subgraphs) == n
      valid_result = [
          [
              [1],
              [4, 4],
              ["5", "5"],
              [2, 2],
              [1, 1, 1],
              ["5", 1, 1],
              [2, 2, 2],
              [1, 1, 1],
              [1, "5", 1],
              [2, 2, 2],
              [7, 7, 7],
              [4, 1, 1],
              [6, 3, 6],
              [7, 7, 7],
              [1, 4, 1],
              [6, 6, 6],
              [4, 1, 1],
              [1, 1, 1],
          ]
      ]
  
      valid_result = [[_conv(x) for x in y] for y in valid_result]
      assert _recursive_items_equal(subgraphs, valid_result)
  
      nodes = _conv([1])
      n_size = [2, 0]
      n = 2
      subgraphs = bfw.run(
          nodes=nodes, n=n, n_size=n_size, seed=19893839
      )
      assert len(subgraphs) == n
      valid_result = [
          [
              [1],
              [4, 4],
              ["5", "5"],
              [2, 2],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
          ],
          [
              [1],
              [4, 4],
              [4, 4],
              [2, 2],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
              [],
          ],
      ]
      valid_result = [[_conv(x) for x in y] for y in valid_result]
      assert _recursive_items_equal(subgraphs, valid_result)
  
file_path: stellargraph/tests/data/test_heterogeneous_breadth_first_walker.py
imports: import pandas
  import numpy
  import pytest
  from stellargraph.data.explorer import SampledHeterogeneousBreadthFirstWalk
  from stellargraph.core.graph import StellarGraph
  from ..test_utils.graphs import example_graph_random
label_desc: Use image node_id 4 for calling the TestSampledHeterogeneousBreadthFirstWalk obj's underlying member method code with example usage: obj.test_walk_generation_single_root_node() and returns: unknown