简体   繁体   English

如何在python中将igraph结果导出到csv文件中?

[英]How to export igraph result in csv file in python?

I wrote code below to show graph with igraph package, But I don't know How can I export igraph result in csv file in python?我写了下面的代码来显示带有 igraph 包的图形,但我不知道如何在 python 中将 igraph 结果导出到 csv 文件中? and my another question is how can I add label?我的另一个问题是如何添加标签?

import igraph as ig 
import pandas as pd
g=ig.Graph.TupleList(df.itertuples(index=False),directed=True)
ig.plot(g, target='graph.png', vertex_size=10, bbox=(0, 0, 500, 500))

Because I want to import that in gephi application I need csv file因为我想在 gephi 应用程序中导入它,所以我需要 csv 文件

Here is the list of formats that igraph can export to:以下是 igraph 可以导出为的格式列表:

https://igraph.org/python/api/latest/igraph.Graph.html#writehttps://igraph.org/python/api/latest/igraph.Graph.html#write

This is the list of formats supported by Gephi:这是 Gephi 支持的格式列表:

https://gephi.org/users/supported-graph-formats/ https://gephi.org/users/supported-graph-formats/

Choose one that is common to both and use that.选择两者通用的一个并使用它。


If you insist on CSV-like formats, NCOL comes closest.如果您坚持使用类似 CSV 的格式,则 NCOL 最接近。 You can also use the get_edgelist() method to get the list of vertex pairs representing edges, then export them using Python's own facilities .您还可以使用get_edgelist()方法获取表示边的顶点对列表,然后使用 Python 自己的工具导出它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM