def detect_unboundedness(R, s, t):
 q = deque([s])
 seen = set([s])
 inf = R.graph['inf']
 while q:
  u = q.popleft()
  for (v, attr) in R[u].items():
   if ((attr['capacity'] == inf) and (v not in seen)):
    if (v == t):
     raise nx.NetworkXUnbounded('Infinite capacity path, flow unbounded above.')
    seen.add(v)
    q.append(v)

def detect_unboundedness ( R , s , t ) : q = deque ( [ s ] ) seen = set ( [ s ] ) inf = R . graph [ 'inf' ] while q : u = q . popleft ( ) for ( v , attr ) in R [ u ] . items ( ) : if ( ( attr [ 'capacity' ] == inf ) and ( v not in seen ) ) : if ( v == t ) : raise nx . NetworkXUnbounded ( 'Infinite capacity path, flow unbounded above.' ) seen . add ( v ) q . append ( v )
detect an infinite-capacity s-t path in r .