class_docstr: Tests for anchor search with scipy.sparse.
class_docstr_tok: ["Tests","for","anchor","search","with","scipy.sparse","."]
docstr: Test bfs.
code: def test_bfs(self):
      """Test bfs."""
      self.instance: pykeen.nn.node_piece.ScipySparseAnchorSearcher
      k = 2
      max_iter = 3
      edge_index = numpy.stack(
          [
              numpy.arange(self.num_entities - 1),
              numpy.arange(1, self.num_entities),
          ]
      )
      adjacency = self.instance.create_adjacency(edge_index=edge_index)
      anchors = numpy.arange(3)
      # determine pool using anchor searcher
      pool = self.instance.bfs(
          anchors=anchors,
          adjacency=adjacency,
          max_iter=max_iter,
          k=k,
      )
      # determine expected pool using shortest path distances via scipy.sparse.csgraph
      distances = scipy.sparse.csgraph.shortest_path(
          csgraph=adjacency,
          directed=False,
          return_predecessors=False,
          unweighted=True,
          indices=anchors,
      )
      k_dist = numpy.partition(distances, kth=k, axis=0)[:k, :].T.max(
          axis=1
      )
      exp_pool = ((distances <= k_dist) & (k_dist <= max_iter)).T
  
      numpy.testing.assert_array_equal(pool, exp_pool)
  
imports: import random
  from typing import Any, MutableMapping
  import numpy
  import numpy.testing
  import pytest
  import scipy.sparse.csgraph
  import unittest_templates
  import pykeen.nn.node_piece
  from tests import cases
  from tests.utils import needs_packages
label_desc: Use image node_id 1 for calling the ScipySparseAnchorSearcherTests obj's underlying member method code with example usage: obj.test_bfs() without return types