【问题标题】:How to get export from igraph in python?如何从python中的igraph导出?
【发布时间】:2021-12-09 13:07:15
【问题描述】:

我编写了这段代码来转换 .gml 格式的数据,但我得到了这个错误。我该怎么办?

TypeError: descriptor 'write_gml' for 'igraph._igraph.GraphBase' objects doesn't apply to a 'str' object

代码:

import igraph as ig
import pandas as pd


a = pd.DataFrame(Matrix, index=tags, columns=tags)


# # Get the values as np.array, it's more convenenient.
A = a.values
# print(A)
# # Create graph, A.astype(bool).tolist() or (A / A).tolist() can also be used.
g = igraph.Graph.Adjacency((A > 0).tolist())

# # Add edge weights and node labels.
g.es['weight'] = A[A.nonzero()]
g.vs['label'] = tags  # or a.index/a.columns

ig.Graph.write_gml('test.gml')

【问题讨论】:

    标签: python matrix igraph


    【解决方案1】:

    如果要将图形g 写入filename,则需要调用g.write_gml(filename)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-08
      • 2019-07-06
      • 2018-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多