Preferential Attachment

Supported Graph Characteristics

Unweighted edges

Directed edges

Undirected edges

Homogeneous vertex types

Heterogeneous vertex types

Algorithm Link: Preferential Attachment

Preferential Attachment is a measure to compute the closeness of vertices based on the number of their neighbors. The algorithm returns the product of the number of neighbors of the first vertex and the number of neighbors of the second vertex.

For more information, see Preferential Attachment.

Notes

Preferential attachment as a metric works best on graphs that have an "unequal" structure where a majority of vertices have few connections and a minority of vertices have many connections.

This algorithm ignores edge weights.

Specifications

CREATE QUERY tg_preferential_attachment(VERTEX a, VERTEX b,
    SET<STRING> e_type)

Parameters

Name Description Data type

VERTEX a

The first vertex to compare.

N/A

VERTEX b

The second vertex to compare with the first.

N/A

SET<STRING> e_type

Edge types to traverse.

(A blank set of strings)

Time complexity

The algorithm has a time complexity of \(O(D1 + D2)\), where \(D1\) and \(D2\) are the degrees of the two vertices.

Return value

The product of the number of neighbors of the two vertices.

Example

Suppose we have the following graph:

preferential attachment ex

Since Dan has four neighbors, while Jenny has three, the return value of the algorithm is \(3*4=12\).

  • Query

  • Result

RUN QUERY preferential_attachment (("Jenny", "person"), ("Dan", "person"), ["friendship"])
{
  "error": false,
  "message": "",
  "version": {
    "schema": 1,
    "edition": "enterprise",
    "api": "v2"
  },
  "results": [{"closeness": 12}]
}