def simple_loops(g, u):
    """
    iterator over the list of simple loops of graph g at the undersample rate u
    """
    gx = graph2nx(num2CG(g2num(undersample(g, u)), len(g)))
    for l in networkx.simple_cycles(gx):
        yield l
Beispiel #2
0
def try_till_path(g, gt):
    d = len(g) - 1
    gx = graph2nx(g)
    sccl = [x for x in strongly_connected_components(gx)]
    # take the largest
    ln = [len(x) for x in sccl]
    idx = np.argsort(ln)
    d = len(sccl[idx[-1]]) - 1
    sccl = [sccl[i] for i in idx[::-1]]
    order = [item for sublist in sccl for item in sublist]
    k = []
    while not k:
        if d < 5:
            return []
        k = try_till_d_path(g, d, gt)
        d -= 1
    return k