graph_plgs.py 文件源码

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

项目:imagepy 作者: Image-Py 项目源码 文件源码
def run(self, ips, imgs, para = None):
        edges, nodes = [], []
        ntitles = ['PartID', 'NodeID', 'Degree','X', 'Y']
        etitles = ['PartID', 'StartID', 'EndID', 'Length']
        k, unit = ips.unit
        comid = 0
        for g in nx.connected_component_subgraphs(ips.data, False):
            for idx in g.nodes():
                o = g.node[idx]['o']
                print(idx, g.degree(idx))
                nodes.append([comid, idx, g.degree(idx), round(o[1]*k,2), round(o[0]*k,2)])
            for (s, e) in g.edges():
                eds = g[s][e]
                for i in eds:
                    edges.append([comid, s, e, round(eds[i]['weight']*k, 2)])
            comid += 1

        IPy.table(ips.title+'-nodes', nodes, ntitles)
        IPy.table(ips.title+'-edges', edges, etitles)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号