code: def test_walk_generation_many_root_nodes(self):
      g = create_test_graph()
      mrw = UniformRandomMetaPathWalk(g)
  
      nodes = ["0", 2]
      n = 1
      length = 15
      metapaths = [["s", "n", "n", "s"]]
      seed = 42
  
      walks = mrw.run(
          nodes=nodes,
          n=n,
          length=length,
          metapaths=metapaths,
          seed=seed,
      )
      assert (
          len(walks) == 1
      )  # the starting node 2 should not generate a walk because it is of type 'n' not 's'
      assert len(walks[0]) <= length  # test against maximum walk length
  
      metapaths = [["s", "n", "n", "s"], ["n", "n", "s", "n"]]
  
      walks = mrw.run(
          nodes=nodes,
          n=n,
          length=length,
          metapaths=metapaths,
          seed=seed,
      )
      assert (
          len(walks) == 2
      )  # each starting node will generate one walk from each metapath
      for walk in walks:
          assert len(walk) <= length  # test against maximum walk length
  
      n = 2
      nodes = ["0", "5"]
      metapaths = [["s", "n", "n", "s"]]
      walks = mrw.run(
          nodes=nodes,
          n=n,
          length=length,
          metapaths=metapaths,
          seed=seed,
      )
      assert len(walks) == n * len(
          nodes
      )  # each starting node will generate one walk from each metapath
      for walk in walks:
          assert len(walk) <= length  # test against maximum walk length
  
      n = 2
      nodes = ["0", "5", 1, 6]
      metapaths = [["s", "n", "n", "s"]]
      walks = mrw.run(
          nodes=nodes,
          n=n,
          length=length,
          metapaths=metapaths,
          seed=seed,
      )
      assert (
          len(walks) == n * 2
      )  # the first two starting node will generate one walk from each metapath
      for walk in walks:
          assert len(walk) <= length  # test against maximum walk length
  
      n = 5
      nodes = ["0", "5", 1, 6]
      metapaths = [["s", "n", "n", "s"], ["n", "s", "n"], ["n", "n"]]
      walks = mrw.run(
          nodes=nodes,
          n=n,
          length=length,
          metapaths=metapaths,
          seed=seed,
      )
      assert len(walks) == n * 6
      for walk in walks:
          assert len(walk) <= length
  
file_path: stellargraph/tests/data/test_metapath_walker.py
imports: import pandas
  import numpy
  import pytest
  from stellargraph.data.explorer import UniformRandomMetaPathWalk
  from stellargraph.core.graph import StellarGraph
  from ..test_utils.graphs import example_graph_random
label_desc: Use image node_id 5 for calling the TestMetaPathWalk obj's underlying member method code with example usage: obj.test_walk_generation_many_root_nodes() without return types