ontology_graph.py 文件源码

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

项目:MetaSRA-pipeline 作者: deweylab 项目源码 文件源码
def graphviz(self, root_id=None):
        g = pgv.AGraph(directed='True')               

        # Breadth-first traversal from root
        visited_ids = Set()
        curr_id = root_id
        q = Queue()
        q.put(curr_id)
        while not q.empty():
            curr_id = q.get()
            visited_ids.add(curr_id)                    
            for sub_id in self.id_to_term[curr_id].inv_is_a():
                if not sub_id in visited_ids:
                    g.add_edge(self.id_to_term[curr_id].name, 
                        self.id_to_term[sub_id].name)
                    q.put(sub_id)
        print str(g)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号