I have the following network of court judgments in the form of a big network.(50k+ nodes and 100k+ edges with weight values). The size is the number of citations. The idea is that court judgments work on precedents (stare decisis), they cite previous judgments. So the most important cases can be either

  • The ones with most citations (ie in-degree centrality)
  • The ones with high eigenvector centrality values

But they don't take into account the fact that edges have weight. HITS or Pagerank also do not take into account - weighted edges. What is the best way to calculate centrality (ie the most important nodes) in the case of a directed network with weighted edges? Does Gephi have any inbuilt tools to do so?


  • $\begingroup$ Welcome to Cross Validated. Are you only interested in a solution using Gephi? The igraph package available in R and Python has an eigenvector centrality algorithm with an option to include tie weights. If that is of interest I can explain at more depth in an answer. $\endgroup$ – Antoine Vernet Sep 3 '18 at 11:57
  • $\begingroup$ I would have liked to use gephi, but I just discovered - they don't incorporate any kind of edgeweight in their link analysis algorithms. I used pagerank with weights using networkx package in python and that seems like a satisfactory solution. But would an eigenvector centrality be statistically more accurate than a weighted pagerank? $\endgroup$ – user10046100 Sep 3 '18 at 12:24

I do not use Gephi, but using weights is quite easy in igraph (available both for R and Python). One approach using igraph in R would be the following:


set.seed <-  100
# let's create a network with some weighted ties
net <- sample_smallworld(1, 100, 6, p = 0.01, loops = FALSE, multiple = FALSE)
net <- as.directed(net, mode = c("mutual"))

weights <- sample(1:10, size = ecount(net), replace = TRUE)
#let's create a weigth attribute
net <- set_edge_attr(net, "weight", value = weights)

#degree weighted
deg_w <- strength(net, mode = c("in"), weights = edge_attr(net, "weight"))

#eigenvector centrality
ecent <- eigen_centrality(net, directed = TRUE, scale = TRUE, 
                          weights = edge_attr(net, "weight"))

Eigenvector centrality can behave erratically with weighted and directed graphs and page rank might be more appropriate in your case.

pr <- page_rank(net, directed = TRUE, damping = 0.85, weights = edge_attr(net, "weight"))
| cite | improve this answer | |
  • $\begingroup$ Thanks for your time! Something similar in the case of python too. rankings=nx.pagerank(G, alpha=0.85, personalization=None, max_iter=100, tol=1e-06, nstart=None, weight='weight', dangling=None) $\endgroup$ – user10046100 Sep 4 '18 at 8:06
  • $\begingroup$ I don't know network x, but it seems the difference is that the implementation in igraph has an argument to allow for the computation to be adjusted for directed networks (the second argument in my code). Igraph is also available in Python, so you might be able to give it a try without having to switch your analysis to R. $\endgroup$ – Antoine Vernet Sep 4 '18 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.