generate_gexf.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:freshonions-torscraper 作者: dirtyfilthy 项目源码 文件源码
def build_graph():
    graph = networkx.DiGraph()
    domain_ids = get_domains_ids()
    total = len(domain_ids)
    i = 0
    seen = dict()
    for d_id in domain_ids:
        i += 1
        domain     = Domain.get(id=d_id)
        links_from = domain.links_from()
        commit()
        if domain.host not in seen:
            graph.add_node(domain.host)
            seen[domain.host] = True

        for link in links_from:
            if link.host not in seen:
                graph.add_node(link.host)
                seen[link.host] = True
            graph.add_edge(domain.host, link.host) 

        if (i % 10) == 0:
            print("Processed %d / %d" % (i, total))

    return graph
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号