Updated on 2022-02-22 GMT+08:00

K-hop

Overview

K-hop is an algorithm used to search all nodes in the k layer that are associated with the source node through breadth-first search (BFS). The found sub-graph is the source node's ego-net. The K-hop algorithm returns the number of nodes in the ego-net.

Application Scenarios

This algorithm applies to scenarios such as relationship discovery, influence prediction, and friend recommendation.

Parameter Description

Table 1 K-hop algorithm parameters

Parameter

Mandatory

Description

Type

Value Range

Default Value

k

Yes

Number of hops

Integer

1-100

-

source

Yes

Node ID

String

-

-

mode

No

Direction:

  • OUT: Hop from the outgoing edges.
  • IN: Hop from the incoming edges.
  • All: Hop from edges in both directions.

String

OUT, IN, ALL

OUT

Precautions

  • A larger k value indicates a wider node coverage area.
  • According to the six degrees of separation theory, all people in social networks will be covered after six hops.
  • BFS searches information based on edges.

Example

Calculate the sub-graph formed by the three hops starting from the Lee node.

Set parameters k to 3, source to Lee, and mode to OUT. The sub-graph is displayed on the canvas, and the JSON result is displayed in the query result area.