Class Node2Vec

Inheritance Relationships

Base Type

Class Documentation

class Node2Vec : public NetworKit::Algorithm

Feature extraction by node2vec algorithm.

Public Functions

Node2Vec(const Graph &G, double P = 1, double Q = 1, count L = 80, count N = 10, count D = 128)

Node2Vec learns embeddings for nodes in a graph by optimizing a neighborhood preserving objective. In order to achieve this, biased random walks are initiated for every node and the result is of probabilistic nature. Several input parameters control the specific behavior of the random walks. Amongst others Node2Vec is able to produce embeddings for visualization (D=2 or D=3) and machine learning (D=128 [default]). Both directed and undirected graphs withouth isolated nodes are supported.

This implementation is an adaption of the original code from snap: https://github.com/snap-stanford/snap

Parameters:
  • G – The graph.

  • P – Walk Return parameter (stay local).

  • Q – Walk In-Out parameter (drift away).

  • L – Walk length.

  • N – Walk count.

  • D – Dimension of embedding vectors.

~Node2Vec() override = default
virtual void run() override

This method computes all node embeddings.

const std::vector<std::vector<float>> &getFeatures() const

This method returns a vector that contains feature vectors for all nodes