Question

I am working with a citation network and I would like to calculate the sum of probabilities of visiting a given node in the network from any other node in the network on a random walk. My understanding is that currentflow_betweeness_centrality is a metric that is similar to this idea, but it does not seem to work with directed grpahs:

import networkx as nx
import pandas as pd
df = pd.read_csv(open("PATH TO CSV","rb"))

DG = nx.DiGraph()

DG.add_edges_from(zip(df.citing.values, df.cited.values))
largest_component = nx.weakly_connected_component_subgraphs(DG)[0]
random_walk = nx.current_flow_betweenness_centrality(largest_component)

As outout, I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/networkx/algorithms/centrality/current_flow_betweenness.py", line 223, in current_flow_betweenness_centrality
    'not defined for digraphs.')
networkx.exception.NetworkXError: ('current_flow_betweenness_centrality() ', 'not defined for digraphs.')

Any ideas on how why this limitation exists?

Was it helpful?

Solution

Current flow betweenness centrality is not formally defined for directed graphs. Maybe in your case you are looking for one of the other centrality measures such as PageRank or degree centrality? See http://networkx.lanl.gov/reference/algorithms.link_analysis.html http://networkx.lanl.gov/reference/algorithms.centrality.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top