UltipaDocs
Try Playground
  • Introduction
    • Show Algorithms
    • Install and Uninstall
    • Run Algorithms
    • Algorithm Results and Statistics
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Graph Centrality
    • Betweenness Centrality
    • Eigenvector Centrality
    • CELF
    • PageRank
    • ArticleRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • K-Hop All
    • Bipartite Graph
    • HyperANF
    • Connected Component
    • Triangle Counting
    • Induced Subgraph
    • k-Core
    • k-Truss
    • p-Cohesion
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Topological Sort
    • Schema Overview
    • Dijkstra's Single-Source Shortest Path
    • Delta-Stepping Single-Source Shortest Path
    • Shortest Path Faster Algorithm (SPFA)
    • Minimum Spanning Tree
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Louvain
    • Leiden
    • Label Propagation
    • HANP
    • k-Means
    • kNN (k-Nearest Neighbors)
    • K-1 Coloring
    • Conductance
      • Random Walk
      • Node2Vec Walk
      • Node2Vec
      • Struc2Vec Walk
      • Struc2Vec
      • GraphSAGE
      • GraphSAGE Train
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Analytics & Algorithms
  4. /
  5. Algorithms

Node2Vec Walk

✓ File Writeback ✕ Property Writeback ✓ Direct Return ✓ Stream Return ✕ Stats

Overview

Diverging from the classic random walk, the Node2Vec Walk is a biased random walk which can explore neighborhoods in a BFS as well as DFS fashion. Please refer to the Node2Vec algorithm for details.

Considerations

  • Self-loops are also eligible to be traversed during the random walk.
  • If the walk starts from an isolated node without any self-loop, the walk halts after the first step as there are no adjacent edges to proceed to.
  • The Node2Vec Walk algorithm ignores the direction of edges but calculates them as undirected edges.

Syntax

  • Command:algo(random_walk_node2vec)
  • Parameters:
Name

Type
Spec
Default
Optional
Description
ids / uuids[]_id / []_uuid//YesID/UUID of nodes to start random walks; start from all nodes if not set
walk_lengthint≧11YesDepth of each walk, i.e., the number of nodes to visit
walk_numint≧11YesNumber of walks to perform for each specified node
edge_schema_property[]@<schema>?.<property>Numeric type, must LTE/YesEdge property(-ies) to use as edge weight(s), where the values of multiple properties are summed up; nodes only walk along edges with the specified property(-ies)
pfloat>01YesThe return parameter; a larger value reduces the probability of returning
qfloat>01YesThe in-out parameter; it tends to walk at the same level when the value is greater than 1, otherwise it tends to walk far away
limitint≧-1-1YesNumber of results to return, -1 to return all results

Example

The example graph is as follows, numbers on edges are the values of edge property score:

File Writeback

Spec
Content
Description
filename_id,_id,...IDs of visited nodes
UQL
algo(random_walk_node2vec).params({
  walk_length: 6,
  walk_num: 2,
  p: 10000, 
  q: 0.0001
}).write({
  file:{
    filename: 'walks'
}})

Results: File walks

File
J,G,H,I,H,G,
I,H,G,F,E,C,
H,G,H,G,F,E,
G,H,G,H,I,H,
F,G,E,C,D,F,
E,F,E,F,G,H,
D,C,D,C,E,F,
C,D,A,B,A,C,
B,A,C,D,F,E,
A,B,A,B,A,C,
J,G,F,D,C,A,
I,H,G,F,E,C,
H,I,H,I,H,G,
G,F,D,C,E,F,
F,E,C,A,B,A,
E,F,E,F,D,C,
D,F,D,F,E,C,
C,D,A,B,A,C,
B,A,C,E,F,G,
A,C,A,C,E,F,

Direct Return

Alias OrdinalType
Description
Columns
0[]perWalkArray of UUIDs of visited nodes[_uuid, _uuid, ...]
UQL
algo(random_walk_node2vec).params({
  ids: ['J'],
  walk_length: 6,
  walk_num: 3,
  p: 2000,
  q: 0.001
}) as walks
return walks

Results: walks

[10, 7, 6, 5, 3, 1]
[10, 7, 6, 5, 3, 1]
[10, 7, 8, 9, 8, 7]

Stream Return

Alias OrdinalType
Description
Columns
0[]perWalkArray of UUIDs of visited nodes[_uuid, _uuid, ...]
UQL
algo(random_walk_node2vec).params({
  ids: ['A'],
  walk_length: 5,
  walk_num: 10,
  p: 1000,
  q: 1,
  edge_schema_property: 'score'
}).stream() as walks
return walks

Results: walks

[1, 3, 4, 6, 5]
[1, 2, 1, 3, 5]
[1, 2, 1, 3, 4]
[1, 3, 4, 6, 7]
[1, 3, 4, 6, 7]
[1, 3, 5, 6, 7]
[1, 3, 5, 6, 4]
[1, 2, 1, 3, 5]
[1, 3, 4, 6, 7]
[1, 3, 4, 6, 5]