

def find_pseudo_peripheral_node_pair(G, start=None):
    if (start is None):
        u = next(G.nodes_iter())
    else:
        u = start
    lp = 0
    v = u
    while True:
        spl = nx.shortest_path_length(G, v)
        l = max(spl.values())
        if (l <= lp):
            break
        lp = l
        farthest = [n for (n, dist) in spl.items() if (dist == l)]
        (v, deg) = sorted(G.degree(farthest).items(), key=itemgetter(1))[0]
    return (u, v)

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/utils/rcm.py find_pseudo_peripheral_node_pair/original