Advanced
Overview
After pairing all neighbors of a node, local clustering coefficient is the probability obtained by dividing the number of pairs which two nodes have edge in between by the number of all pairs.
Local clustering coefficient can be used to examine the tightness of the ego network of node. For example, in social network, it reveals how familiar the friends of one person are, which can help to distinguish the type of social group, such as relatives and friends, communities, agents, etc.
Basic Concept
Ego Network
Ego network is a subgraph formed by one center node (Ego) and all its 1-step neighbors (Alter). Please read the related content in Induced Subraph algorithm for the introduction to subgraph.

Specifying the red node in the graph above as Ego, its ego network contains the red node, the green nodes and all the red edges.
Local Clustering Coefficient
Local clustering coefficient is obtained by dividing the number of neighbor pairs of a node which two nodes have edge in between by the number of all neighbor pairs of that node.

x
in the formula above represents the node to be calculated, i
and j
are any two distinct neighbors in x
's ego network; δ(i,j)
is 1 when there is edge between i
and j
, and 0 otherwise; k
is the number of nodes in x
's ego network, that is, (k-1)(k-2)/2
is the number of node pairs of i
and j
.

For the ego network of the red node in the graph above, only yellow-green and blue-purple node pairs have edge in between, thus the local clustering coefficient of the red node is 2 / 6 = 0.3333
.
Special Case
Lonely Node, Disconnected Graph
Lonely node does not connect with any other node, its local clustering coefficient is 0, and it does not participate in the calculation of any local clustering coefficient.
Nodes in one connected component must not participate in the calculation of the local clustering coefficient of nodes in other connected components.
Self-loop Edge
Self-loop edge of a node does not increase the number of neighbors of the node.
Directed Edge
For directed edges, Local Clustering Coefficient algorithm ignores the direction of edges but calculates them as undirected edges.
Command
algo(clustering_coefficient).params(<>)
Configuration Item | Type | Default Value | Specification | Description |
---|---|---|---|---|
ids | []_id |
(All nodes) | Ultipa ID | The list of ID of nodes to be calculated |
uuids | []_uuid |
(All nodes) | Ultipa UUID | The list of UUID of nodes to be calculated |
limit | int | -1 | -1 or >=0 | Number of results to return, -1 means to return all results |
order | string | / | ASC or DESC, case insensitive | To sort the retuned results, no sorting is applied if not set |
Example: Calculate the local clustering coefficient of nodes (UUID = 1,2,3)
algo(clustering_coefficient).params({ uuids: [1,2,3], limit: -1 })
File Writeback
.write({file: {<>}})
Parameter | Type | Default Value | Specification | Description |
---|---|---|---|---|
filename | string | / | / | Name of the file path to be written back. Columns of the file are: _id ,centrality |
Property Writeback
.write({db: {<>}})
Parameter | Type | Default Value | Specification | Description |
---|---|---|---|---|
property | string | / | / | Name of the node property to be written back. Write the local clustering coefficient back to: <property> |
Statistics Writeback
(Not supported)
Direct Return
as <alias> return <alias>
Alias Number | Type | Description | Column Name |
---|---|---|---|
0 | []perNode | Node and its local clustering coefficient | _uuid , centrality |
Streaming Return
.stream() as <alias> return <alias>
Alias Number | Type | Description | Column Name |
---|---|---|---|
0 | []perNode | Node and its local clustering coefficient | _uuid , centrality |
Real-time Statistics
(Not supported)