Lostsoul
Lostsoul

Reputation: 26009

How can I factor in weights into networkx's pagerank algorithm?

I think I'm doing this inefficiently right now and wanted a suggestion of how to do this better. Currently I have a directed graph and am using node specific factors(i.e. analyzing the nodes and then assigning scores to edges between the two). I have many factors and keep changing the weights of the edges(in my case the higher the weight the better).

But those are node specific, I also wanted to exploit the structure of the graph to make inferences as well(more edges should give a node a better ranking, etc..).

My problem is these are two different processes that are occurring and I want to see if I can somehow combine the two together to make inferences. Right now, I am running pagerank on my nodes(each set of nodes is split my days, so I run pagerank on the entire dataset then only capture the results for the current day), then take the current days pagerank scores and add them to the total of all the weights from the various edges to the nodes. It gets a bit confusing and I was wondering if there was another way or if I can get pagerank to consider edge weights(or something else..I can easily modify the program)?

My fear with my current approach is as I add more factors to study for each node the scores will increase(each node adds a value between 0-1) but the pagerank scores stay small, so if a a node has a score of 25 and a pagerank of .034, then relatively the pagerank score will not play a big role in inference on the graph.

Any help or suggestions would be great. I've done a bit of reading on graphs but I'm still a n00b so please correct any incorrect assumptions I have made. Also, if it helps, I'm using python and networkx library for my graph.

Upvotes: 1

Views: 655

Answers (1)

Scott Hunter
Scott Hunter

Reputation: 49813

If your primary concern is the relative weight between nodes scores and page ranks, can't you just alter their weights to get the proper balance? For example, instead of summing the factors for a score, if you used the average, then the number of factors wouldn't be an issue.

Upvotes: 2

Related Questions