1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! Local Clustering coefficient - measures the degree to which nodes in a graph tend to cluster together.
//!
//! It is calculated by dividing the number of triangles (sets of three nodes that are all
//! connected to each other) in the graph by the total number of possible triangles.
//! The resulting value is a number between 0 and 1 that represents the density of
//! clustering in the graph.
//!
//! A high clustering coefficient indicates that nodes tend to be
//! connected to nodes that are themselves connected to each other, while a low clustering
//! coefficient indicates that nodes tend to be connected to nodes that are not connected
//! to each other.
//!
//! In a social network of a particular community_detection, we can compute the clustering
//! coefficient of each node to get an idea of how strongly connected and cohesive
//! that node's neighborhood is.
//!
//! A high clustering coefficient for a node in a social network indicates that the
//! node's neighbors tend to be strongly connected with each other, forming a tightly-knit
//! group or community_detection. In contrast, a low clustering coefficient for a node indicates that
//! its neighbors are relatively less connected with each other, suggesting a more fragmented
//! or diverse community_detection.
//!
//! # Examples
//!
//! ```rust
//! use raphtory::algorithms::metrics::clustering_coefficient::local_clustering_coefficient::local_clustering_coefficient;
//! use raphtory::prelude::*;
//!
//! let g = Graph::new();
//! let windowed_graph = g.window(0, 7);
//! let vs = vec![
//! (1, 1, 2),
//! (2, 1, 3),
//! (3, 2, 1),
//! (4, 3, 2),
//! (5, 1, 4),
//! (6, 4, 5),
//! ];
//!
//! for (t, src, dst) in &vs {
//! g.add_edge(*t, *src, *dst, NO_PROPS, None);
//! }
//!
//! let actual = (1..=5)
//! .map(|v| local_clustering_coefficient(&windowed_graph, v))
//! .collect::<Vec<_>>();
//!
//! println!("local clustering coefficient of all nodes: {:?}", actual);
//! ```
use crate::;
/// Local clustering coefficient - measures the degree to which a single node in a graph tend to cluster together.
///
///
/// # Arguments
/// - `graph`: Raphtory graph, can be directed or undirected but will be treated as undirected.
/// - `v`: node id or name
///
/// # Returns
/// the local clustering coefficient of node v in g.