CSGraphAnchorSearcher

class CSGraphAnchorSearcher[source]

Bases: AnchorSearcher

Find closest anchors using scipy.sparse.csgraph.

Methods Summary

__call__(edge_index, anchors, k[, num_entities])

Find the \(k\) closest anchor nodes for each entity.

Methods Documentation

__call__(edge_index, anchors, k, num_entities=None)[source]

Find the \(k\) closest anchor nodes for each entity.

Parameters
  • edge_index (ndarray) – shape: (2, m) the edge index

  • anchors (ndarray) – shape: (a,) the selected anchor entity Ids

  • k (int) – the number of closest anchors to return

  • num_entities (Optional[int]) – the number of entities

Return type

ndarray

Returns

shape: (n, k), -1 <= res < a the Ids of the closest anchors