I found an example showing how to calculate LCC by hand (see image).
How can I replicate these steps in R? Focus is on finding the "Actual number of links among Neighbors" (middle step)
I would preferably have to calculate it by hand
*Does the igraph package provide this number?
Example adjacency matrix:
matrix(data = c(0,1,0,1,1,0,0,1,1,1,0,1,1,0,1,0), ncol = 4)
All of this can be done in
igraph
. It is nice that you gave an example, but since the graph is fully connected, all vertices have LCC=1. I decided to use a somewhat more complicated graph. I will go through the "by hand" part in detail for vertex 1.Sample graph
To start with, yes, igraph has a built-in function
transitivity
for LCC. For my sample graph, you can get this withBut the main part of your question is the hand computation. The only things that you need from the graph are the first two steps - the Degree Centrality and the Actual Links Among Neighbors.
Degree Centrality is given by the
degree
functionAs you suggested in your question, the only challenging part is the Actual Links Among Neighbors. You can get this by taking the subgraph induced by the neighbors of a point and then checking the number of edges. So for vertex 1 we get
Here is the full computation for vertex 1
which agrees with
transitivity
given above.