Search code examples
python-3.xnodesnetworkxconnectivityedges

Python `nx.maximum_flow_value`


I'm using the following code sample in Python to calculate the flow between every pair of nodes in the graph below to identify whether the graph is 2 connected. It returns that the graph is 2 connected and all pairs of nodes have flow >=2, which is false because the marked area has a cut node. I can't identify what I'm doing wrong. Can someone please help me with that?

for edge in list(T.edges()):
    T[edge[0]][edge[1]]['capacity']=1
    T[edge[1]][edge[0]]['capacity']=1

flow3 =[]

for d in V: 
    tempvert =[]
    tempvert = set(V) - set([d])    
    for a in tempvert:
        flow_value = nx.maximum_flow_value(T, a, d,capacity = '1')

enter image description here


Solution

  • Try using nx.node_connectivity(G). Here is the documentation.