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


so on and so forth for about 2000 graph IDs, each with about 20-40
vertices.  I've tried using the "split" command but it doesn't recognize my
graph id: ("object 'graphid' not found)--this may just be because I don't
know how to classify a column of a csv as an object.


Ultimately, 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)
convert cs`i'$membership into a column in the original csv

}


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

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to