Total Neighbors
The algorithm counts the total number of neighbors, or vertices connected by one hop, of two vertices.
Specifications
CREATE QUERY tg_total_neighbors(VERTEX v_source VERTEX v_target,
SET<STRING> e_type)
Parameters
Name | Description | Default value |
---|---|---|
|
The first vertex to compare. Provide the vertex ID and type as a tuple: |
N/A |
|
The second vertex to compare with the first. Provide the vertex ID and type as a tuple: |
N/A |
|
Edge types to traverse. |
(an empty set of strings) |
Example
Suppose we have the following graph.
Dan and Jenny together have 6 neighbors in total.
Dan’s neighbors are:
-
Nancy
-
Kevin
-
Tom
-
Jenny
and Jenny’s neighbors are:
-
Dan
-
Tom
-
Amily
Running the algorithm with input vertices of Dan
and Jenny
would give us a result of 6
because the connection Dan - Jenny and Jenny - Dan is not double-counted.