def detect_unboundedness(R, s, t):
    """Detect an infinite-capacity s-t path in R.
    """
    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)
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/flow/utils.py/detect_unboundedness/original