igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Question about exporting community detection results


From: Vivian Huang
Subject: [igraph] Question about exporting community detection results
Date: Tue, 29 May 2018 23:02:30 -0400

Dear all

I used igraph in R to detect communities based on an unweighted unidirectional edge list like the following:

ID1      ID2
1278    2876
3354    9973
.....................
5350    6672

The edge list was saved in a CSV file : "I:/network/ Edges 1997 to 1999.csv"

The code I wrote :

dat=read.csv(file.choose("I:/network/ Edges 1997 to 1999.csv"),header=TRUE)
el=as.matrix(dat)
el[,1]=as.character(el[,1])
el[,2]=as.character(el[,2])
g=graph.edgelist(el,directed=FALSE)
cluster_louvain(g,weights=NULL)

The code worked well.  However, I couldn't figure out how to export the community detection results to a CSV file.   I would like to have a dataset that looks like the following (the third column being the ID of a community that a row belongs to):

ID1      ID2     CommunityID
1278    2876       A
3354    9973       C
.....................
5350    6672       A

Thank you for your help in advance!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]