How to write a dataframe, graph to pajek format?

我们两清 提交于 2019-12-25 05:32:29

问题


I Would like to save a igraph graph or a dataframe to pajek format. So I have used the igraph package to create graph object and then used this write.graph(graph_activitynetwork,"layer_share","pajek") to write the igraph graph in pajek.but what I am wondering is to create it in customized format :like this :

*Vertices 4
1 "Node 1"
2 "Node 2"
3 "Node 3"
4 "Node 4"
*Multiplex
# layer node layer node [weight]
1 1 1 2 2
1 1 2 2 1
1 2 1 1 1

now I could just have this format :

*Vertices 4
1 "1"
2 "2"
3 "3"
4 "4"
*Edges
# node node weight
1 2 l 
1 3 l 
1 4 l 

Ps: My own data is in csv and Excel format.

node1 node2 weight layer

the graph summary :

IGRAPH UNW-  -- 
+ attr:  id (v/c),  weight (e/c), layer1 (e/c),layer2 (e/c)

来源:https://stackoverflow.com/questions/28818695/how-to-write-a-dataframe-graph-to-pajek-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!