[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] automating computations on multiple graphs
From: |
Gábor Csárdi |
Subject: |
Re: [igraph] automating computations on multiple graphs |
Date: |
Fri, 6 May 2011 10:57:23 -0400 |
For the records, this questions was answered here:
http://r.789695.n4.nabble.com/Looping-over-graphs-in-igraph-td3499550.html
Gabor
On Thu, May 5, 2011 at 2:23 PM, Danielle Li <address@hidden> wrote:
> 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 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
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
--
Gabor Csardi <address@hidden> MTA KFKI RMKI