Exemplo n.º 1
0
def test_ncp_localmin():
    G = load_example_graph()
    ncp = lgc.NCPData(G)
    func = lgc.partialfunc(lgc.spectral_clustering,alpha=0.01,rho=1.0e-4,method="acl")

    ncp.default_method = func
    ncp.add_localmin_samples(ratio=1)
    print(ncp.as_data_frame())


    G = lgc.GraphLocal()
    G.list_to_gl([0,1],[1,0],[1,1])
    ncp = lgc.NCPData(G)
    func = lgc.partialfunc(lgc.spectral_clustering,alpha=0.01,rho=1.0e-4,method="acl")

    ncp.default_method = func
    ncp.add_localmin_samples(ratio=1)
Exemplo n.º 2
0
def test_apr_refine():
    G = load_example_graph()
    df = lgc.NCPData(G).approxPageRank(ratio=1,
                                       gamma=0.1,
                                       rholist=[1e-2, 1e-3],
                                       random_neighborhoods=False,
                                       localmins=False,
                                       spectral_args={
                                           'refine':
                                           lgc.partialfunc(lgc.flow_clustering,
                                                           method="mqi")
                                       })
Exemplo n.º 3
0
def test_ncp():
    G = load_example_graph()
    ncp = lgc.NCPData(G)
    df = ncp.as_data_frame()
    assert len(df) == 0
    ncp.mqi(nthreads=1,ratio=1.0)
    df = ncp.as_data_frame()
    assert len(df) == G._num_vertices
    #func = lambda G,R: lgc.flow_clustering(G,R,method="mqi")[0]
    func = lgc.partialfunc(lgc.flow_clustering, method="mqi")
    ncp = lgc.NCPData(G)
    ncp.add_set_samples([[1]],nthreads=1,method=func,methodname="mqi")
    ncp.add_random_neighborhood_samples(ratio=2,nthreads=1,method=func,methodname="mqi")