コード例 #1
0
ファイル: rdomset.py プロジェクト: ctb/spacegraphcats
def main(inputgxt, outputgxt, d, test, domgraph):
    g, node_attrs, edge_attrs = Graph.from_gxt(inputgxt)
    g.remove_loops()

    domset, augg = rdomset(g,d)
    print "Computed {}-domset of size {} in graph with {} vertices".format(d,len(domset),len(g))

    dominators = calc_dominators(augg, domset, d)

    # Compute domset graph
    if domgraph:
        print "Computing domgraph"
        h = calc_domset_graph(domset, dominators, d)
        write_gxt(domgraph, h)

    # Test domset
    if test:
        print "Testing domset:", test_domset(g,domset,d)

    # Annotate domset
    labelds = 'ds{}'.format(d)
    for v in domset:
        node_attrs[v][labelds] = 1

    write_gxt(outputgxt, g, node_attrs, edge_attrs)
コード例 #2
0
ファイル: fvs.py プロジェクト: ctb/spacegraphcats
def main(inputgxt,outputgxt):
    g,node_attrs,edge_attrs = Graph.from_gxt(inputgxt)

    agraph = AGraph()
    for u,v in g.edges(): # We don't care about degree-zero vertices
        agraph.add_edge(u,v)
    solution = fvs(agraph)

    # Annotate solution
    for v in solution:
        node_attrs[v]['fvs'] = 1

    write_gxt(outputgxt, g, node_attrs, edge_attrs)
コード例 #3
0
ファイル: atlas.py プロジェクト: ctb/spacegraphcats
def main(inputgraph, inputhash, output, hash_size, d_bottom, d_upper, top_level_size, test):
    G,node_attrs,edge_attrs = Graph.from_gxt(inputgraph)
    hashes = read_minhashes(inputhash)

    for v in G:
        assert v in hashes, "{} has no minhash".format(v)

    G.remove_loops()
    AB = AtlasBuilder(G, hashes, hash_size, d_bottom, d_upper, top_level_size)
    print "Input graph has size", len(G)
    atlas = AB.build_atlas()
    atlas.to_file(output)

    print "Atlas has {} leaves".format(len(atlas.leaves()))