示例#1
0
def main(args):
    data = load_data(args)
    g = data.graph
    if isinstance(g, dgl.DGLGraph):
        csr = g.adjacency_matrix_scipy(transpose=True)
    else:
        csr = nx.to_scipy_sparse_matrix(g, weight=None, format='csr')

    graph_io.save_graph(args.out, csr)
示例#2
0
def main(args):
    if args.dataset == 'segtree':
        g = build_segtree(batch_size=32, seq_len=512)
        print('#Nodes: %d #Edges: %d' % (g.number_of_nodes(), g.number_of_edges()))
        csr = g.adjacency_matrix_scipy(fmt='csr')        
    else:
        data = load_data(args)
        g = data.graph
        csr = nx.to_scipy_sparse_matrix(g, weight=None, format='csr')

    graph_io.save_graph(args.out, csr)
示例#3
0
def main(args):
    if args.dataset == 'segtree':
        g = build_segtree(batch_size=32, seq_len=512)
        print('#Nodes: %d #Edges: %d' %
              (g.number_of_nodes(), g.number_of_edges()))
        csr = g.adjacency_matrix_scipy(fmt='csr')
        n, m = 32 * 512, 32 * 512
    else:
        data = load_data(args)
        g = data.graph
        if isinstance(g, dgl.DGLGraph):
            csr = g.adjacency_matrix_scipy(transpose=True)
        else:
            csr = nx.to_scipy_sparse_matrix(g, weight=None, format='csr')
        n, m = csr.indptr.shape[0] - 1, csr.indptr.shape[0] - 1

    graph_io.save_graph(args.out, csr, n, m)
def compare_modules(m_g0, g_m0, m_g1, g_m1, g0, g1):
    """
        currently saves two images of the biggest module for graph0 and graph1.
    """
    print 'calling compare_modules'
    top10_0 = get_top_n_modules(m_g0, 10)
    top10_1 = get_top_n_modules(m_g1, 10)

    top_module_genes0 = list(m_g0[top10_0[0]])
    top_module_genes1 = list(m_g1[top10_1[0]])

    H0 = g0.subgraph(top_module_genes0)
    H1 = g1.subgraph(top_module_genes1)

    print top_module_genes0
    print top_module_genes1
    print top_module_genes0 == top_module_genes1

    print 'saving the two biggest modoles'

    #todo get this to display the same graph, since edgelist is the same?
    graph_io.save_graph(H0, '../results/Merlin/h0.png')
    graph_io.save_graph(H1, '../results/Merlin/h1.png')
示例#5
0
def gen_er(args):
    g = nx.fast_gnp_random_graph(args.er_n, args.er_p)
    csr = nx.to_scipy_sparse_matrix(g, weight=None, format='csr')
    graph_io.save_graph(args.out, csr, args.er_n, args.er_n)
示例#6
0
def gen_ba(args):
    g = nx.barabasi_albert_graph(args.ba_n, args.ba_m)
    csr = nx.to_scipy_sparse_matrix(g, weight=None, format='csr')
    graph_io.save_graph(args.out, csr, args.er_n, args.er_n)