the cypher is:
CREATE
(home:Page {name:'Home'}),
(about:Page {name:'About'}),
(product:Page {name:'Product'}),
(links:Page {name:'Links'}),
(a:Page {name:'Site A'}),
(b:Page {name:'Site B'}),
(c:Page {name:'Site C'}),
(d:Page {name:'Site D'}),
(home)-[:LINKS {weight: 0.2}]->(about),
(home)-[:LINKS {weight: 0.2}]->(links),
(home)-[:LINKS {weight: 0.6}]->(product),
(about)-[:LINKS {weight: 1.0}]->(home),
(product)-[:LINKS {weight: 1.0}]->(home),
(a)-[:LINKS {weight: 1.0}]->(home),
(b)-[:LINKS {weight: 1.0}]->(home),
(c)-[:LINKS {weight: 1.0}]->(home),
(d)-[:LINKS {weight: 1.0}]->(home),
(links)-[:LINKS {weight: 0.8}]->(home),
(links)-[:LINKS {weight: 0.05}]->(a),
(links)-[:LINKS {weight: 0.05}]->(b),
(links)-[:LINKS {weight: 0.05}]->(c),
(links)-[:LINKS {weight: 0.05}]->(d);
CALL gds.eigenvector.stream('paGraph', {
maxIterations: 20,
relationshipWeightProperty: 'weight'
})
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).name AS name, score
ORDER BY score DESC, name ASC
I use the C library.code is:
#include <igraph.h>
int main(void) {
igraph_t graph;
igraph_vector_int_t edges;
igraph_vector_t weights;
igraph_vector_t pagevector;
igraph_real_t value;
// Create a vector for edges and weights
igraph_vector_int_init(&edges, 30);
igraph_vector_init(&weights, 15);
// Define edges. The graph has 9 nodes, numbered 0 to 8.
// Format: VECTOR(edges)[Edge * 2] = Source; VECTOR(edges)[Edge * 2 + 1] =
// Target; home-0 about-1 product-2 linkes-3 SiteA-4 SiteB-5 SiteC-6 SiteD-7
VECTOR(edges)[0] = 0;
VECTOR(edges)[1] = 1; // Home -> About
VECTOR(edges)[2] = 0;
VECTOR(edges)[3] = 3; // Home -> Links
VECTOR(edges)[4] = 0;
VECTOR(edges)[5] = 2; // Home -> Product
VECTOR(edges)[6] = 1;
VECTOR(edges)[7] = 0; // About -> Home
VECTOR(edges)[8] = 2;
VECTOR(edges)[9] = 0; // Product -> Home
VECTOR(edges)[10] = 4;
VECTOR(edges)[11] = 0; // Site A -> Home
VECTOR(edges)[12] = 5;
VECTOR(edges)[13] = 0; // Site B -> Home
VECTOR(edges)[14] = 6;
VECTOR(edges)[15] = 0; // Site C -> Home
VECTOR(edges)[16] = 7;
VECTOR(edges)[17] = 0; // Site D -> Home
VECTOR(edges)[18] = 3;
VECTOR(edges)[19] = 0; // Links -> Home
VECTOR(edges)[20] = 3;
VECTOR(edges)[21] = 4; // Links -> Site A
VECTOR(edges)[22] = 3;
VECTOR(edges)[23] = 5; // Links -> Site B
VECTOR(edges)[24] = 3;
VECTOR(edges)[25] = 6; // Links -> Site C
VECTOR(edges)[26] = 3;
VECTOR(edges)[27] = 7; // Links -> Site D
// Define weights for each edge
VECTOR(weights)[0] = 0.2; // Home -> About
VECTOR(weights)[1] = 0.2; // Home -> Links
VECTOR(weights)[2] = 0.6; // Home -> Product
VECTOR(weights)[3] = 1.0; // About -> Home
VECTOR(weights)[4] = 1.0; // Product -> Home
VECTOR(weights)[5] = 1.0; // Site A -> Home
VECTOR(weights)[6] = 1.0; // Site B -> Home
VECTOR(weights)[7] = 1.0; // Site C -> Home
VECTOR(weights)[8] = 1.0; // Site D -> Home
VECTOR(weights)[9] = 0.8; // Links -> Home
VECTOR(weights)[10] = 0.05; // Links -> Site A
VECTOR(weights)[11] = 0.05; // Links -> Site B
VECTOR(weights)[12] = 0.05; // Links -> Site C
VECTOR(weights)[13] = 0.05; // Links -> Site D
// Create the graph
igraph_create(&graph, &edges, 0, IGRAPH_DIRECTED);
// Initialize eigenvector
igraph_vector_init(&pagevector, 0);
// igraph_pagerank(&graph, IGRAPH_PAGERANK_ALGO_PRPACK, &pagevector, &value,
// igraph_vss_all(), IGRAPH_DIRECTED,
// /* damping */ 0.85, /* weights */ &weights,
// NULL /* not needed with PRPACK method */);
igraph_eigenvector_centrality(&graph, &pagevector, &value,
IGRAPH_DIRECTED,
/*scale=*/ true, &weights, /*options=*/
NULL);
// Print the results
for (int i = 0; i < igraph_vector_size(&pagevector); i++) {
printf("Node %li has eigenvector centrality %.12f.\n", (long int)i,
VECTOR(pagevector)[i]);
}
// Clean up
igraph_vector_destroy(&pagevector);
igraph_vector_int_destroy(&edges);
igraph_vector_destroy(&weights);
igraph_destroy(&graph);
return 0;
}
the neo4j result:
name |score |
-------±-------------------+
Home | 0.8328163407319487|
Product| 0.5004775834976312|
About | 0.16682586116587708|
Links | 0.16682586116587708|
Site A |0.008327591469710233|
Site B |0.008327591469710233|
Site C |0.008327591469710233|
Site D |0.008327591469710233|
but the igraph result is:
Node 0 has eigenvector centrality 1.000000000000.
Node 1 has eigenvector centrality 0.200000000000.
Node 2 has eigenvector centrality 0.600000000000.
Node 3 has eigenvector centrality 0.200000000000.
Node 4 has eigenvector centrality 0.010000000000.
Node 5 has eigenvector centrality 0.010000000000.
Node 6 has eigenvector centrality 0.010000000000.
Node 7 has eigenvector centrality 0.010000000000.
if I used a wrong function?