Same Community (Beta)

This algorithm takes two vertices, and returns 1 if they two vertices are in the same community, and returns 0 if they are not in the same community.

The algorithm assumes that community detection has already completed and that a community ID is stored in an integer attribute on each vertex.

Specifications

CREATE QUERY tg_same_community(VERTEX a, VERTEX b, STRING
    communityAttribute)

Parameters

Name

Description

Data type

a

A vertex.

VERTEX

b

A vertex.

VERTEX

communityAttribute

The community attribute used to store a vertex’s community ID.

STRING

Return value

  • Returns 1 if the two vertices are in the same community.

  • Returns 0 if the two vertices are not in the same community.

Example

Suppose we have the following vertices:

Their community IDs were generated by running the weakly connected component algorithm on the graph. If we run the algorithm between Kevin and Jenny, we get 1 because the two vertices are in the same community as indicated by their community attribute:

RUN QUERY tg_same_community (("Jenny", "person"), ("Kevin", "person"), 
    "community")

Last updated