igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] injecting a network and simulating it.


From: Gábor Csárdi
Subject: Re: [igraph] injecting a network and simulating it.
Date: Thu, 25 Apr 2013 10:34:56 -0400

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):

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) {
round(mean(V(net)$Opinion[neighbors(net,x)])))
plot(net, vertex.color=colbar[V(net)$Opinion], layout=coords)





On Thu, Apr 25, 2013 at 10:17 AM, suvirbhargav <address@hidden> wrote:
i'm trying to simulate a Non-concensus opinion(NCO) model on a Network,say  ER for example.
In NCO network,two opinion(say +ve and -ve for example) co-exists together in steady state.For example, presidential election with two candidates and opinion  changes and eventually reaches a steady state,when no more change of opinoin happens.
Regards
Suvir

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




--
Gabor Csardi <address@hidden>     MTA KFKI RMKI

reply via email to

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