igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] union of graphs


From: Gábor Csárdi
Subject: Re: [igraph] union of graphs
Date: Thu, 16 Oct 2008 14:44:32 +0200

I'm not sure how to do this in Python, but here is how to do it in R.
Maybe something similar is possible in Python.

# Two graphs, merged based on their 'name' vertex attribute
g1 <- erdos.renyi.game(100, p=5/100)
g2 <- erdos.renyi.game(100, p=5/100)

V(g1)$name <- sample(1:100)
V(g2)$name <- sample(1:100)

el1 <- get.edgelist(g1, names=TRUE)
el2 <- get.edgelist(g2, names=TRUE)

el <- rbind(el1, el2)
mode(el) <- "character"      # not needed is 'name' contains strings
g <- graph.edgelist(as.character(el), directed=FALSE)

Best,
Gabor

On Mon, Oct 13, 2008 at 5:59 PM, Marco <address@hidden> wrote:
> Hi,
>
> let's suppose i have n graphs, which are randomly generated, with
> igraph.Graph.Erdos_Renyi.
> Now, let's suppose i want to make an union of m of those graphs, with
> some selection rule.
> Basically i want to take a node in the graph 1 and connect it to a
> node in the graph 2, then again for every couple of graphs in set of n
> graphs.
>
> Suggestions on how i can do it with igraph (i am using the python frontend)?
>
> Thanks in advance for you help,
>
> marco
>
>
> --
>
> è il gioco della vita,
> la dobbiamo preparare
> che non ci sfugga dalle dita
> come la sabbia in riva al mare.
>
> Lucio Dalla
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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