# Calculating Information centrality for complex network

I want to add the information centrality metric to my analysis of complex network. Is there any in built function or library that I can use in mathematical. I did not come across any algorithm with clear idea how to implement this.

Update: If I use the algorithm as mentioned in the literature above I get a situation that the inverse of the matrix cannot be calculated (mathematica displays as singular matrix ) as shown below

Data is:

adjCitationData = {
{18, 5, 2,  4 ,   9,  0,  0,  5, 0, 3,   1,   5,    0,   0},
{  3, 6, 0,  2 ,   2,  0,  0,  0, 0, 0,   0,   1,   0,    0},
{  1, 3, 3,  4 ,   3,  0,  0,  0, 0, 0,   0,   1,   0,    0},
{  9, 0, 0, 68,  25,  0,  0,  0, 0, 6,  12,   0,   6,    0},
{19, 4, 1, 57, 139,  0,  0, 0, 0, 7,  62,  0,  44,  0},
{  1, 0, 0,  0 ,   0,  5,  4,  0, 0,  0,   0,    0,   0,   0},
{  1, 0, 0,  0 ,   0,  3,  2,  0, 0,  0,   0,    0,   0,   0},
{  6, 0, 0,  0 ,   1,  0,  0,  2, 0,  0,   0,    3,   0,   0},
{  0, 0, 0,  0 ,   0,  0,  0,  0, 0,  0,   0,    0,   0,   0},
{  0, 0, 0,  0 ,   0,  0,  0,  0, 0,  0,   0,    0,   0,   0},
{  8, 2, 0, 44 , 85, 0,  0,  0, 0,  4,  53,   0,  35,  0},
{  8, 1, 0,  0 ,   1,  1,  0,  2, 0,  0,   0,    6,   0,   0},
{  1, 0, 0, 25 , 59,  0,  0, 0, 0,  1,  47,   0,  37,  0},
{  0, 0, 0,  0 ,   0,   0,  0,  0, 0,  0,    0,    0,   0,   0} }

n = 14;
diagD = DiagonalMatrix[DCr];
matJ = Table[1, {i, n}, {j, n}];
matB = diagD - adjCitationData + matJ;
Inverse[matB];
invB = Inverse[matB] // N;
infoC[i_, j_] := invB[[i, i]] + invB[[j, j]] - 2*invB[[i, j]];
Inverse[matB];(*Inverse cannot be calculated as determinant is zero*)
Dimensions[matB]


I am I doing this correctly.

• Can you define what you mean by informational centrality? There are many centrality measures in Mathematica such as betweenness, degree, eigenvalue centralities so on. May 4, 2022 at 19:08
• Can you provide the full reference of the paper developing the centrality measure? If possible, send the link to the paper. May 4, 2022 at 21:27
• In your matrix adjCitationData , the last row and the last columns are all zero. You should drop the zero rows and columns from this matrix. Then, the algorithm works fine, otherwise, the matrix cannot be converted to a graph. May 5, 2022 at 8:59

@Tugrul Temels answer followed the paper instructions and works fine. Here is the fine-tuned version of that code which is around one order of magnitude faster:

ClearAll[informationCentrality];
informationCentrality[g_] :=
Block[{b =
Inverse[1. + DiagonalMatrix[DegreeCentrality[g]] -

bDiagonal = Diagonal[b];
Outer[Plus, bDiagonal, bDiagonal] - 2 * b
]


### Comparison

(* Tugrul Temels answer *)
TugrulTemel[g_] := Block[{n = VertexCount[g], invB},
invB = Inverse[
Table[invB[[i, i]] + invB[[j, j]] - 2*invB[[i, j]], {i, n}, {j, n}]
]

g = RandomGraph[{70, 260}]

informationCentrality[g] == TugrulTemel[g]
(* Out: True *)

informationCentrality[g]; // RepeatedTiming
(* Out: {0.000533871, Null} *)

TugrulTemel[g]; // RepeatedTiming
(* Out: {0.0123265, Null} *)

• Nice, compact and efficient code. Thanks. May 5, 2022 at 8:36
• @Ben lzd I have problem with inversing the matrix. The sample data I have added in the Updated question. Is there any way to overcome this. May 5, 2022 at 10:15
• @SyedIftekharuddin I think it's because your graph is not weakly connected and has separate components. May 5, 2022 at 11:07
• @BenIzd I have added my graph for visualization. Could you please suggest how to overcome this. May 5, 2022 at 11:18
• For your specific graph which has 1 main component, you can try (assuming graph is save in a variable called g): informationCentrality[First[TakeLargestBy[WeaklyConnectedGraphComponents[g],EdgeCount,1]]]. This will give you the main component's information centrality without the two isolated vertices. May 5, 2022 at 14:09

Here is an example with a 5 by 5 matrix.

ClearAll[adjA, adjG, degD, diagD, matJ, matB];
SeedRandom[11];
diagD = DiagonalMatrix[degD]; (* Diagonal Degree Matrix of degD *)
matJ = Table[1, {i, 5}, {j, 5}];  (* matrix with all elements 1 *)
matB = diagD - adjA + matJ; (* matrix B *)
Inverse[matB] // N; (* inverse of matB *)

infoC[i_, j_] := invB[[i, i]] + invB[[j, j]] - 2*invB[[i, j]]; (* definition of informational centrality *)


Example: i=2, j=4;

infoC[2,4]
(* 0.320202 *)


You can then calculate any centrality value using infoC[i,j].

UPDATE A generalization of the centrality measure for any directed graph with n vertices;

ClearAll[n, adjA, adjG, degD, diagD, matJ, matB, invB];
SeedRandom[11];
n = 10; (* number of vertices *)
adjA = RandomInteger[{0, 1}, {n, n}];