|
From: | Danielle Li |
Subject: | [igraph] automating computations on multiple graphs |
Date: | Thu, 5 May 2011 14:23:52 -0400 |
Hi,
I'm
trying to do some basic social network analysis with igraph in R, but
I'm new to R and haven't been able to find documentation on a couple
basic things:
I want to run igraph's community detection
algorithms on a couple thousand small graphs but don't know how to automate igraph looking at multiple graphs described in a single csv file. My data look like something in ncol format, but with an additional column that has an ID for which graph the edge belongs in:
Graph ID | Vertex1 | Vertex2 | weight
1 | Alice | Bob | 2
1 | Alice | Chris | 1
1 | Alice | Jane | 2
1 | Bob | Jane | 2
1 | Chris | Jane | 3
2 | Alice | Tom | 2
2 | Alice | Kate | 1
2 | Kate | Tom | 3
2 | Tom | Mike | 2
I want to run community detection on each graph separately--to look only at the edges when the graph identifier is 1, make calculations on that graph, then do it again for 2 and so forth. I suspect that this isn't related to igraph specifically--I just don't know the equivalent command in R for what in pseudo Stata code would read as:
forvalues i of 1/N {
temp_graph=subrows of the main csv file for which graphid==`i'
cs`i' = leading.eigenvector.community.step(temp_graph)
}
I want the output to look something like:
Graph ID | Vertex1 | Vertex2 | weight | Vertex 1 membership | Vertex 2 membership | # of communities in the graph
1 | Alice | Bob | 2 | A | B | 2
1 | Alice | Chris | 1 | A | B | 2
1 | Alice | Jane | 2 | A | B | 2
1 | Bob | Jane | 2 | B | B | 2
1 | Chris | Jane | 3 | B | B | 2
2 | Alice | Tom | 2 | A | B | 3
2 | Alice | Kate | 1 | A | C | 3
2 | Kate | Tom | 3 | C | B | 3
2 | Tom | Mike | 2 | B | C | 3
Here, the graphs are treated completely separately so that community A in graph 1 need not have anything to do with community A in graph 2.
I would really appreciate any ideas you guys have.
Thank you!
Danielle
[Prev in Thread] | Current Thread | [Next in Thread] |