Local Clustering Coefficient
The Local Clustering Coefficient algorithm computes the local clustering coefficient of every vertex in a graph. The local clustering coefficient of a vertex (node) in a graph quantifies how close its neighbors are to being a complete graph, where every two distinct vertices are connected by an edge.
It is obtained by dividing the number of edges between a vertex’s neighbors by the number of edges that could possibly exist.
For more information, see Clustering Coefficient.
Notes
The algorithm does not report the local clustering coefficient for vertices that have only one neighbor.
Local Clustering Coefficient only works with directed graphs if reverse edges are included.
Specifications
tg_lcc(STRING v_type, STRING e_type,INT top_k=100,
BOOL print_accum = True, STRING result_attr = "",
STRING file_path = "", BOOL display_edges = FALSE)
Parameters
Parameter  Description  Data type 


Vertex type to calculate local clustering coefficient for 


Edge type to traverse. Only vertices that are connected by edges of this type are treated as connected in this algorithm. 


Number of the highest local clustering coefficients to report. 


If 


If provided, the local clustering coefficient of a vertex will be saved to this attribute. 


If provided, write output to this file in CSV. 


If 

Example
Using the social
graph below as an example, Jenny has three neighbors  Tom, Dan and Amily, but only Tom and Dan are connected. Between the three neighbors, the maximum number of edges that could exist is 3. Therefore, the local clustering coefficient for Jenny is 1/3.
On the other hand, Tom has two neighbors that are connected by one edge. Since the maximum number of edges that could exist between two vertices is 1, Tom has a local clustering coefficient of 1/1 = 1.
By running the algorithm in GSQL, we can confirm that Tom has the highest local clustering coefficient with a score of 1 and Jenny has a score of 1/3.
RUN QUERY tg_lcc("person", "friendship", _, _, _, _, _)
{
"error": false,
"message": "",
"version": {
"schema": 0,
"edition": "enterprise",
"api": "v2"
},
"results": [{"top_scores": [
{
"score": 1,
"Vertex_ID": "Tom"
},
{
"score": 0.33333,
"Vertex_ID": "Jenny"
},
{
"score": 0.16667,
"Vertex_ID": "Dan"
},
{
"score": 0,
"Vertex_ID": "Nancy"
}
]}]
}