UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Managing HDC Graphs
  • Managing Distributed Projections
  • Installing Algorithms
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Graph Centrality
    • Betweenness Centrality
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • 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
      • 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

Struc2Vec Walk

HDC

Overview

The Struc2Vec Walk is a biased random walk and serves as a key component of the Struc2Vec framework. Unlike traditional random walks, it operates on a constructed multi-layer weighted graph instead of the original graph. For more details, please refer to the Struc2Vec algorithm.

Example Graph

Run the following statements on an empty graph to define its structure and insert data:

INSERT (A:default {_id: "A"}),
       (B:default {_id: "B"}),
       (C:default {_id: "C"}),
       (D:default {_id: "D"}),
       (E:default {_id: "E"}),
       (F:default {_id: "F"}),
       (G:default {_id: "G"}),
       (H:default {_id: "H"}),
       (I:default {_id: "I"}),
       (J:default {_id: "J"}),
       (A)-[:default]->(B),
       (A)-[:default]->(C),
       (D)-[:default]->(C),
       (D)-[:default]->(F),
       (E)-[:default]->(C),
       (E)-[:default]->(F),
       (F)-[:default]->(G),
       (G)-[:default]->(J),
       (H)-[:default]->(G),
       (H)-[:default]->(I);

Creating HDC Graph

To load the entire graph to the HDC server hdc-server-1 as my_hdc_graph:

CREATE HDC GRAPH my_hdc_graph ON "hdc-server-1" OPTIONS {
  nodes: {"*": ["*"]},
  edges: {"*": ["*"]},
  direction: "undirected",
  load_id: true,
  update: "static"
}

Parameters

Algorithm name: random_walk_struc2vec

Name
Type
Spec
Default
Optional
Description
ids[]_id//YesSpecifies nodes to start random walk by their _id. If unset, computation includes all nodes.
uuids[]_uuid//YesSpecifies nodes to start random walk by their _uuid. If unset, computation includes all nodes.
walk_lengthInteger≥11YesDepth of each walk, i.e., the number of nodes to visit.
walk_numInteger≥11YesNumber of walks to perform for each specified node.
kInteger[1, 10]/NoNumber of layers in the constructed multilayer weighted graph, which should not exceed the diameter of the original graph.
stay_probabilityFloat(0,1]/NoThe probability of walking in the current level.
return_id_uuidStringuuid, id, bothuuidYesIncludes _uuid, _id, or both values to represent nodes in the results.
limitInteger≥-1-1YesLimits the number of results returned. Set to -1 to include all results.

File Writeback

algo(random_walk_struc2vec).params({
  projection: "my_hdc_graph",
  return_id_uuid: "id",
  walk_length: 5,
  walk_num: 1,
  k: 4,
  stay_probability: 0.8
}).write({
  file:{
    filename: 'walks'
}})

Result:

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

Full Return

exec{
  algo(random_walk_struc2vec).params({
    return_id_uuid: "id",
    ids: ['J'],
    walk_length: 6,
    walk_num: 3,
    k: 4,
    stay_probability: 0.8
  }) as walks
  return walks
} on my_hdc_graph

Result:

_ids
["J","G","F","C","B"]
["J","F","H","F","J"]
["J","G","J","H","F"]

Stream Return

exec{
  algo(random_walk_struc2vec).params({
    return_id_uuid: "id",
    ids: ['J'],
    walk_length: 6,
    walk_num: 3,
    k: 5,
    stay_probability: 0.7
  }).stream() as walks
  return walks
} on my_hdc_graph

Result:

_ids
["J","G","I","F"]
["J","E","J"]
["J","H","F","A"]