ScipySparseAnchorSearcher
- class ScipySparseAnchorSearcher(max_iter: int = 5)[source]
Bases:
AnchorSearcher
Find closest anchors using
scipy.sparse
.Initialize the searcher.
- Parameters:
max_iter (int) – the maximum number of hops to consider
Methods Summary
__call__
(edge_index, anchors, k[, num_entities])Find the \(k\) closest anchor nodes for each entity.
bfs
(anchors, adjacency, max_iter, k)Determine the candidate pool using breadth-first search.
create_adjacency
(edge_index[, num_entities])Create a sparse adjacency matrix from a given edge index.
Iterate over the components of the
extra_repr()
.select
(pool, k)Select \(k\) anchors from the given pools.
Methods Documentation
- __call__(edge_index: ndarray, anchors: ndarray, k: int, num_entities: int | None = None) ndarray [source]
Find the \(k\) closest anchor nodes for each entity.
- Parameters:
- Returns:
shape: (n, k), -1 <= res < a the Ids of the closest anchors
- Return type:
- static bfs(anchors: ndarray, adjacency: spmatrix, max_iter: int, k: int) ndarray [source]
Determine the candidate pool using breadth-first search.
- Parameters:
- Returns:
shape: (n, a) a boolean array indicating whether anchor \(j\) is in the set of \(k\) closest anchors for node \(i\)
- Return type:
- static create_adjacency(edge_index: ndarray, num_entities: int | None = None) spmatrix [source]
Create a sparse adjacency matrix from a given edge index.
- iter_extra_repr() Iterable[str] [source]
Iterate over the components of the
extra_repr()
.This method is typically overridden. A common pattern would be
def iter_extra_repr(self) -> Iterable[str]: yield from super().iter_extra_repr() yield "<key1>=<value1>" yield "<key2>=<value2>"