Local Clustering Coefficient for vertex tells us howe close its neighbors are. It's number of existing connections in neighborhood divided by number of all possible connections.
LC(x)=\sum_{v \in N(x)}{\frac{|N(x) \cap N(v)|}{|N(x)|*(|N(x)|-1)}}
Where N(x) is set of neighbours of vertex x
For further informations please refer to [Watts].
import ml.sparkling.graph.operators.OperatorsDSL._
import org.apache.spark.SparkContext
import org.apache.spark.graphx.Graph
implicit ctx:SparkContext=???
// initialize your SparkContext as implicit value
val graph =???
// load your graph (for example using Graph loading API)
val centralityGraph: Graph[Double, _] = graph.localClustering()
// Graph where each vertex is associated with its local clustering coefficient
You can also compute local clustering coefficient for graph treating it as undirected one:
import ml.sparkling.graph.operators.OperatorsDSL._
import org.apache.spark.SparkContext
import ml.sparkling.graph.api.operators.measures.VertexMeasureConfiguration
import org.apache.spark.graphx.Graph
implicit ctx:SparkContext=???
// initialize your SparkContext as implicit value
val graph =???
// load your graph (for example using Graph loading API)
val centralityGraph: Graph[Double, _] = graph.localClustering(VertexMeasureConfiguration(treatAsUndirected=true))
// Graph where each vertex is associated with its local clustering coefficient computed for undirected graph
References:
[Watts] |
|