networkit.embedding

class networkit.embedding.Node2Vec(G, P, Q, L, N, D)

Bases: networkit.base.Algorithm

Algorithm to extract features from the graph with the node2vec(word2vec) algorithm according to [https://arxiv.org/pdf/1607.00653v1.pdf].

Note

This algorithm could take a lot of time on large networks (many nodes).

Parameters
  • G (networkit.Graph) – The graph.

  • P (float) – The ratio for returning to the previous node on a walk. For P > max(Q,1) it is less likely to sample an already-visited node in the following two steps. For P < min(Q,1) it is more likely to sample an already-visited node in the following two steps.

  • Q (float) – The ratio for the direction of the next step For Q > 1 the random walk is biased towards nodes close to the previous one. For Q < 1 the random walk is biased towards nodes which are further away from the previous one.

  • L (int) – The walk length.

  • N (int) – The number of walks per node.

  • D (int) – The dimension of the calculated embedding.

getFeatures()

Returns all feature vectors

Returns

A vector containing feature vectors of all nodes

Return type

list(list(float))