SingleSelection

class SingleSelection(num_anchors: int = 32)[source]

Bases: AnchorSelection, ABC

Single-step selection.

Initialize the strategy.

Parameters:

num_anchors (int) – the number of anchor nodes to select. # TODO: allow relative

Methods Summary

__call__(edge_index[, known_anchors])

Select anchor nodes.

rank(edge_index)

Rank nodes.

Methods Documentation

__call__(edge_index: ndarray, known_anchors: ndarray | None = None) ndarray[source]

Select anchor nodes.

Note

the number of selected anchors may be smaller than \(k\), if there are less entities present in the edge index.

Parameters:
  • edge_index (ndarray) – shape: (m, 2) the edge_index, i.e., adjacency list.

  • known_anchors (ndarray | None) – numpy.ndarray an array of already known anchors for getting only unique anchors

Returns:

(k,) the selected entity ids

Return type:

ndarray

abstractmethod rank(edge_index: ndarray) ndarray[source]

Rank nodes.

Parameters:

edge_index (ndarray) – shape: (m, 2) the edge_index, i.e., adjacency list.

Returns:

(n,) the node IDs sorted decreasingly by anchor selection preference.

Return type:

ndarray