thanks.That worked! Increasing vertices and edges to higher values makes it slow.(v=10000,e=20000) though. Any optimization technique i can use? Regards Suvir
On Fri, Apr 26, 2013 at 4:22 AM, Gábor Csárdi <[email protected]> wrote: > On Thu, Apr 25, 2013 at 6:08 PM, suvirbhargav <[email protected]> wrote: > >> i changed the code a bit by running neighbour opinion function in loop >> and comparing the opinion "1" of net from past five time step .(assumption >> is network will repeat itself in these five time step in steady state) >> code: http://scsys.co.uk:8002/244444 >> >> How do i change the opinion based not only on neighbour but also node >> itself . >> (as adopted opinion is majority opinion including opinion from both >> neigbour and itself ) >> > > Then use the Opinion attribute of the 'x' vertex as well. > > >> Also,cluster size is there in igrpah already there, but i want to >> calculate largest cluster with opinion "1". >> > > Delete all the vertices that are '2' with delete.vertices(net, > V(g)[opinion==2]) and then call clusters(). > > G. > > >> >> Thanks & Regards >> Suvir >> >> >> >> On Thu, Apr 25, 2013 at 7:02 PM, Gábor Csárdi <[email protected]>wrote: >> >>> See ?sample and the prob argument. G. >>> >>> >>> On Thu, Apr 25, 2013 at 12:54 PM, suvirbhargav <[email protected]>wrote: >>> >>>> thanks. >>>> >>>> In below ,How can i control the percentage of both 1 and 2,say 20% of 1 >>>> and rest 2? >>>> V(net)$Opinion <- sample(1:2, vcount(net), replace=TRUE) >>>> Sorry,this is R question though,may be >>>> >>>> Regards >>>> Suvir >>>> >>>> >>>> On Thu, Apr 25, 2013 at 4:37 PM, Gábor Csárdi <[email protected]>wrote: >>>> >>>>> On Thu, Apr 25, 2013 at 10:34 AM, Gábor Csárdi <[email protected]>wrote: >>>>> >>>>>> I see. Then what you could do is adding a vertex attribute, named >>>>>> (say) "Opinion", and then update that based on the network structure, >>>>>> e.g. >>>>>> (in R): >>>>>> >>>>> >>>>> Sorry, sent it prematurely, this is the correct code: >>>>> >>>>> library(igraph) >>>>> set.seed(42) >>>>> net <- erdos.renyi.game(40, 2/40) >>>>> V(net)$Opinion <- sample(1:2, vcount(net), replace=TRUE) >>>>> >>>>> coords <- layout.auto(net) >>>>> colbar <- c("orange", "cyan") >>>>> layout(rbind(1:2)) >>>>> par(mar=c(0,0,0,0)) >>>>> plot(net, vertex.color=colbar[V(net)$Opinion], layout=coords) >>>>> >>>>> ## Set the opinion based on the neighbors >>>>> V(net)$Opinion <- sapply(V(net), function(x) { >>>>> if (degree(net, x)==0) { >>>>> V(net)$Opinion[x] >>>>> } else { >>>>> round(mean(V(net)$Opinion[neighbors(net,x)])) >>>>> } >>>>> }) >>>>> >>>>> plot(net, vertex.color=colbar[V(net)$Opinion], layout=coords) >>>>> >>>>> G. >>>>> >>>>> [...] >>>>> >>>>> -- >>>>> Gabor Csardi <[email protected]> MTA KFKI RMKI >>>>> >>>>> _______________________________________________ >>>>> igraph-help mailing list >>>>> [email protected] >>>>> https://lists.nongnu.org/mailman/listinfo/igraph-help >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> igraph-help mailing list >>>> [email protected] >>>> https://lists.nongnu.org/mailman/listinfo/igraph-help >>>> >>>> >>> >>> >>> -- >>> Gabor Csardi <[email protected]> MTA KFKI RMKI >>> >>> _______________________________________________ >>> igraph-help mailing list >>> [email protected] >>> https://lists.nongnu.org/mailman/listinfo/igraph-help >>> >>> >> >> _______________________________________________ >> igraph-help mailing list >> [email protected] >> https://lists.nongnu.org/mailman/listinfo/igraph-help >> >> > > > -- > Gabor Csardi <[email protected]> MTA KFKI RMKI > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help > >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
