# NOT RUN {
# This example makes a multipage PDF that contains images
# Of a building network using soft constraints.
# Each step one node is added with one edge. The max.delta
# decreases the longer nodes are present in the network.
pdf("Soft Constraints.pdf",width=10,height=5)
adj=adjO=matrix(0,nrow=3,ncol=3)
adj[upper.tri(adj)]=1
Q=qgraph(adj,vsize=3,height=5,width=10,layout="spring",
esize=1,filetype='',directed=T)
cons=Q$layout
for (i in 1:20)
{
x=nrow(adj)
adjN=matrix(0,nrow=x+1,ncol=x+1)
adjN[1:x,1:x]=adj
consN=matrix(NA,nrow=x+1,ncol=2)
consN[1:x,]=cons[1:x,]
layout.par=list(init=rbind(cons,c(0,0)),
max.delta=10/(x+1):1,area=10^2,repulse.rad=10^3)
y=sample(c(x,sample(1:(x),1)),1)
adjN[y,x+1]=1
Q=qgraph(adjN,Q,layout="spring",layout.par=layout.par)
cons=Q$layout
adj=adjN
}
dev.off()
# }
Run the code above in your browser using DataLab