Search code examples
memgraphdb

How to format the personalization vector for calculating personalized PageRank using nxalg in Memgraph MAGE?


I'm working on a query where I need to calculate the personalized PageRank using the nxalg module provided by Memgraph MAGE. I'm having trouble understanding how to properly represent the personalization vector in the personalisation parameter of the pagerank function. According to the source code, it seems that the personalisation should be a string that gets converted into a dictionary. However, the format of the string and the dictionary keys (whether they should be nodes or node IDs) are unclear to me. Can anyone provide an example or clarification on how the personalisation string should be formatted?


Solution

  • I've glanced the code on the link that you have provided. If I got it right the personalization vector is derived from the graph stored in Memgraph is using the following approach:

    1. Each node in the graph should have a property representing its personalization value. This property should be the same for all nodes in the graph.
    2. You need to pass the property name as an argument to the nxalg.pagerank function. For example, you can call the function using CALL nxalg.pagerank(0.85, "personalizationProperty") YIELD *.

    It seems to me that this design choice is that it is significantly more convenient and efficient to use this method when dealing with large graphs, as opposed to passing an extensive dictionary containing an item for each node in the graph. This way, the personalization information is embedded within the graph itself, making it easier to manage and query the data.