igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Is it possible to generate hierarchical networks using igra


From: Csardi Gabor
Subject: Re: [igraph] Is it possible to generate hierarchical networks using igraph in R
Date: Tue, 23 Sep 2008 10:50:45 +0200
User-agent: Mutt/1.5.9i

My understanding is, that this is completely a tree, the center of 
the star is the root. So 

graph.tree(100, 5)

does exactly what you want. 

If you want to change the neighbors at each 
stage, then you'll have to write a small program for that.
You can use the following code as a starting point:

hierarchy <- function(nodes, neis, directed=FALSE) {
  conn <- matrix(0, nc=2, nr=0)
  leaves <- 0
  cur.nodes <- leaves[length(leaves)]
  while (cur.nodes < nodes) {
    act.neis <- neis[1]
    if (length(neis)>1) neis <- neis[-1]
    from <- rep(leaves, each=act.neis)
    leaves <- seq(cur.nodes+1, by=1, length=act.neis*length(leaves))
    conn <- rbind(conn, cbind( from, leaves ))
    cur.nodes <- leaves[length(leaves)]
  }
  graph( t(conn), directed=directed)
}

'neis' is a vector that gives the number of neighbors at each 
level.

G.

On Sat, Sep 20, 2008 at 11:34:14PM +0100, Amit Kumar wrote:
> Hello,
> I wish to generate a hierarchical network.For this I am thinking of a
> generalization of a star. Say you have a star : 1 center with 5 neighbours
> (the leaves at this stage) only connected to it. From this 5 neighbours you
> draw again 5 neighbours to each (which are the leaves now; the leaves of the
> previous steps become internal nodes) and so on...It looks like a tree but
> has no root. You can also change the number of neighbours at each stage or
> put a degree distribution when you decide to expand from the leaves. I wish
> to generate such network with 100 nodes.
> I will appreciate your help!
> 
> Best
> Amit
> 
> 
> On Tue, Sep 9, 2008 at 10:16 PM, Csardi Gabor <address@hidden> wrote:
> 
> > Amit, which particular model do you have in mind? There is no
> > standard model for hierarchical graphs, as far as I know.
> >
> > G.
> >
> > On Tue, Sep 09, 2008 at 05:29:33PM +0100, Amit Kumar wrote:
> > > Hello,
> > > I need to simulate hierarchical network. Is it possible to generate this
> > > using igraph in R same as erdos.renyi.game() for random graphs by passing
> > > parameters.
> > > Please help!
> > >
> > > regards
> > > Amit
> >
> > > _______________________________________________
> > > igraph-help mailing list
> > > address@hidden
> > > http://lists.nongnu.org/mailman/listinfo/igraph-help
> >
> >
> > --
> > Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK
> >
> >
> > _______________________________________________
> > igraph-help mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/igraph-help
> >

> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help


-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

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