# calculating different centralities for a network

I am new to mathematica. I have an adjacency matrix as shown below. I need to calculate various centralities for this matrix. But there is some strange error that I cannot understand.

mainList = {
{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} };


I removed the zero from the matrix and replace with infinity using the Replace as

mainList = ReplaceAll[0 -> \[Infinity]][mainList];

{{1, 1, 2, 1, 3, 2, 1, 1, 1, 1, 1, 1, 1,
1}, {1, \[Infinity], \[Infinity], \[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {2, \[Infinity], \[Infinity], \
\[Infinity], 4,
2, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {3, 2, 4, 2, 2, 3, 2, 2, 2, 2,
2, 2, 2, 2}, {2, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1,
1}, {1, \[Infinity], \[Infinity], \[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}, {1, \[Infinity], \[Infinity], \
\[Infinity], 2,
1, \[Infinity], \[Infinity], \[Infinity], \[Infinity], \[Infinity], \
\[Infinity], \[Infinity], \[Infinity]}}


I need to calculate the closeness, betweeness and EigenVector centralities as follows: CCm = Mean[IGCloseness@IGWeightedAdjacencyGraph@mainList];

I get the following error (for example for closeness centrality calculation):

I am not sure how to solve this issue.

1. You must load IGraph/M using Needs["IGraphM"] before using any functions from the package. The red syntax colouring of IGWeightedAdjacencyMatrix in your screenshot shows that you have not done so. Restart the kernel, and load the package before doing anything else.
2. It is not necessary to replace zeros with infinities when using IGWeightedAdjacencyMatrix.

You can create a weighted graph from the adjacency matrix like this:

Needs["IGraphM"]


It also makes no sense to compute eigenvector centrality for a disconnected graph. The largest eigenvalue will be degenerate. Furthermore, while eigenvector centrality can be defined for directed graphs in principle, it was not really designed for these. Note that IGEigenvectorCentrality computes the left eigenvector of the adjacency matrix. More details: http://szhorvat.net/mathematica/IGDocumentation/#eigenvector-centrality