dependencygraph.py 文件源码

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

项目:FancyWord 作者: EastonLee 项目源码 文件源码
def nx_graph(self):
        """Convert the data in a ``nodelist`` into a networkx labeled directed graph."""
        import networkx

        nx_nodelist = list(range(1, len(self.nodes)))
        nx_edgelist = [
            (n, self._hd(n), self._rel(n))
            for n in nx_nodelist if self._hd(n)
        ]
        self.nx_labels = {}
        for n in nx_nodelist:
            self.nx_labels[n] = self.nodes[n]['word']

        g = networkx.MultiDiGraph()
        g.add_nodes_from(nx_nodelist)
        g.add_edges_from(nx_edgelist)

        return g
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号