code: def test_weighted_walks(self):
      # all positive walks
      g = weighted(1, 2, 3, 4)
  
      nodes = list(g.nodes())
      n = 1
      length = 1
      seed = None
      p = 1.0
      q = 1.0
  
      biasedrw = BiasedRandomWalk(g)
      assert (
          len(
              biasedrw.run(
                  nodes=nodes,
                  n=n,
                  p=p,
                  q=q,
                  length=length,
                  seed=seed,
                  weighted=True,
              )
          )
          == 4
      )
  
      # all zero-weight edges
      g = weighted(0, 0, 0, 0)
      biasedrw = BiasedRandomWalk(g)
      walks = biasedrw.run(
          nodes=nodes, n=2, p=p, q=q, length=3, weighted=True
      )
      assert len(walks) == 8
      for walk in walks:
          assert len(walk) == 1
  
      # negative edge
      g = weighted(1, -2, 3, 4)
  
      biasedrw = BiasedRandomWalk(g)
  
      neg_message = r"graph: expected all edge weights to be non-negative and finite, found some negative or infinite: 1 to 2 \(weight = -2\)"
  
      with pytest.raises(ValueError, match=neg_message):
          BiasedRandomWalk(g, weighted=True)
  
      with pytest.raises(ValueError, match=neg_message):
          biasedrw.run(
              nodes=nodes,
              n=n,
              p=p,
              q=q,
              length=length,
              seed=seed,
              weighted=True,
          )
  
      # edge with weight infinity
      g = weighted(1, np.inf, 3, 4)
  
      biasedrw = BiasedRandomWalk(g)
  
      inf_message = r"graph: expected all edge weights to be non-negative and finite, found some negative or infinite: 1 to 2 \(weight = inf\)"
      with pytest.raises(ValueError, match=inf_message):
          BiasedRandomWalk(g, weighted=True)
  
      with pytest.raises(ValueError, match=inf_message):
          biasedrw.run(
              nodes=nodes,
              n=n,
              p=p,
              q=q,
              length=length,
              seed=seed,
              weighted=True,
          )
  
imports: import numpy
  import pandas
  import pytest
  import networkx
  from stellargraph.data.explorer import BiasedRandomWalk
  from stellargraph.core.graph import StellarGraph
  from ..test_utils.graphs import create_test_graph, example_graph_random
label_desc: Use image node_id 4 for calling the TestBiasedWeightedRandomWalk obj's underlying member method code with example usage: obj.test_weighted_walks() without return types