Directed graph katz() and eigenvector() centrality
Hello, i've got a question about the gt.eigenvector and gt.katz centrality. Am i right that if i set alpha close to (1/largest eigenvalue) and norm=True in katz() it should return very similar values like the eigenvector() function, right?
for a symmetric adjacency matrix this works:
gt.adjacency(g0).todense()
matrix([[0., 1., 1., 1., 1., 1., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 1., 1., 1., 1.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 1.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 1.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 1.],
[0., 1., 0., 1., 1., 0., 0., 0., 1., 0.]])
eigenval, eigenvec = gt.eigenvector(g0)
print(eigenval)
3.0755541273220803
eigenvec.a
PropertyArray([0.44350442, 0.49485585, 0.14420316, 0.29038013, 0.29038013,
0.14420316, 0.16089968, 0.16089968, 0.30707665, 0.44957503])
gt.katz(g=g0,alpha=(1/eigenval)-0.0001,norm=True).a
PropertyArray([0.44350908, 0.49482438, 0.14426683, 0.29038497, 0.29038497,
0.14426683, 0.16094659, 0.16094659, 0.30706473, 0.44953251])
Now the same graph but directed (not all edges are symmetric now):
gt.adjacency(g1).todense()
matrix([[0., 1., 1., 1., 1., 1., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 1., 1., 1., 0.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 0., 0., 0., 0., 0., 0., 0.],
[0., 1., 0., 1., 1., 0., 0., 0., 1., 0.]])
eigenval, eigenvec = gt.eigenvector(g1)
print(eigenval)
2.5134122979149964
eigenvec.a
PropertyArray([0.49827288, 0.49827288, 0.24913644, 0.24913644, 0.24913644,
0.24913644, 0.16609096, 0.16609096, 0.16609096, 0.4152274 ])
gt.katz(g=g1,alpha=(1/eigenval)-0.0001,norm=True).a
PropertyArray([0.54534079, 0.44822619, 0.22537849, 0.22537849, 0.22537849,
0.22537849, 0.18674965, 0.18674965, 0.18674965, 0.44032779])
Is the solution correct? Am i missing something? If i am doing the same with nx i get similar values for directed graph:
nx.eigenvector_centrality_numpy(G=gnx1)
{<Vertex object with index '0' at 0x1343eded0>: 0.549560615752939, <Vertex object with index '1' at 0x1343edcf0>: 0.44871436377481105, <Vertex object with index '2' at 0x1343ed7b0>: 0.22435718188740525, <Vertex object with index '3' at 0x1343ed990>: 0.22435718188740525, <Vertex object with index '4' at 0x1343ede10>: 0.22435718188740522, <Vertex object with index '5' at 0x1343edf30>: 0.22435718188740536, <Vertex object with index '6' at 0x1343ed870>: 0.18318687191764657, <Vertex object with index '7' at 0x1343ed690>: 0.18318687191764668, <Vertex object with index '8' at 0x1343edd50>: 0.18318687191764663, <Vertex object with index '9' at 0x113b60690>: 0.4411594711310948}
nx.katz_centrality_numpy(G=gnx1,alpha=(1/eigenval)-0.00001,normalized=True)
{<Vertex object with index '0' at 0x1343eded0>: 0.5453769196111444, <Vertex object with index '1' at 0x1343edcf0>: 0.4482311808417871, <Vertex object with index '2' at 0x1343ed7b0>: 0.2253692756640506, <Vertex object with index '3' at 0x1343ed990>: 0.2253692756640506, <Vertex object with index '4' at 0x1343ede10>: 0.2253692756640506, <Vertex object with index '5' at 0x1343edf30>: 0.22536927566405063, <Vertex object with index '6' at 0x1343ed870>: 0.1867193107629488, <Vertex object with index '7' at 0x1343ed690>: 0.18671931076294881, <Vertex object with index '8' at 0x1343edd50>: 0.18671931076294881, <Vertex object with index '9' at 0x113b60690>: 0.4403354169129587}
The gt.katz() values looks similar to the nx onces but the directed gt.eigenvector() values are different. Can someone explain it to me? If its not a bug, sorry for opening.
Thanks in advance