PlanetAlign.algorithms.NeXtAlign

class NeXtAlign(p: float = 1, q: float = 1, num_walks: int = 10, walk_length: int = 80, rwr_restart_prob: float = 0.15, out_dim: int = 128, dist: str = 'L1', batch_size: int = 300, neg_size: int = 20, coeff1: float = 1, coeff2: float = 1, lr: float = 0.01, dtype: dtype = torch.float32)[source]

Bases: BaseModel

Embedding-based method NeXtAlign for pairwise network alignment. NeXtAlign is proposed by the paper: “Balancing Consistency and Disparity in Network Alignment.” in KDD 2021

Parameters:
  • p (float, optional) – Hyperparameter in node2vec. Default is 1.

  • q (float, optional) – Hyperparameter in node2vec. Default is 1.

  • num_walks (int, optional) – Number of random walks during context pair generation. Default is 10.

  • walk_length (int, optional) – Length of each random walk. Default is 80.

  • rwr_restart_prob (float, optional) – Restart probability for random walk with restart. Default is 0.15.

  • out_dim (int, optional) – Dimension of the output embeddings. Default is 128.

  • dist (str, optional) – Distance metric for the similarity matrix. Default is ‘L1’.

  • batch_size (int, optional) – Batch size for training. Default is 300.

  • neg_size (int, optional) – Number of negative samples. Default is 20.

  • coeff1 (float, optional) – Coefficient for the within-network link prediction loss. Default is 1.

  • coeff2 (float, optional) – Coefficient for the anchor link prediction loss. Default is 1.

  • lr (float, optional) – Learning rate for the optimizer. Default is 0.01.

  • dtype (torch.dtype, optional) – Data type of the tensors, choose from torch.float32 or torch.float64. Default is torch.float32.

test(dataset: Dataset, gids: List[int] | Tuple[int, ...], metrics: tuple[str] | list[str] = None)
Parameters:
  • dataset (Dataset) – The dataset containing the graphs to be aligned and the training/test data.

  • gids (list[int] or tuple[int, ...]) – The indices of the graphs in the dataset to be aligned.

  • metrics (tuple[str] or list[str], optional) – The metrics to be computed after alignment. Default is None, which computes Hits@K (K=1, 10, 30, 50) and MRR metrics.

train(dataset: Dataset, gid1: int, gid2: int, use_attr: bool = True, total_epochs: int = 50, save_log: bool = True, verbose: bool = True)[source]
Parameters:
  • dataset (Dataset) – The dataset containing the graphs to be aligned and the training/test data.

  • gid1 (int) – The index of the first graph in the dataset to be aligned.

  • gid2 (int) – The index of the second graph in the dataset to be aligned.

  • use_attr (bool, optional) – Whether to use node attributes in the model. Default is True.

  • total_epochs (int, optional) – Total number of epochs for training. Default is 50.

  • save_log (bool, optional) – Whether to save the training log. Default is True.

  • verbose (bool, optional) – Whether to print the training progress. Default is True.