# Bakule

19\. 4. 2014

Petr Kucera

**************


Konstanta n je pocet vrcholu. G je stejne jako $/Gamma$


```{r}
n=22
b=14
G=1000

nula=cbind(rep(0,n));
dvojka=cbind(rep(2,n));
soused=dvojka
postihy=nula
for (t in 2:n)
  {soused=cbind(soused,dvojka);postihy=cbind(postihy,nula)}

pomoc=soused

Q=array(rep(0,n*b*n),dim=c(n,b,n))


casy=cbind(nula,nula)
casy[1,1]=rexp(n=1,rate=1/3)

for (t in 2:n)
  {casy[t,1]=rexp(n=1,rate=1/6)
   casy[t,2]=rexp(n=1,rate=1/2)+casy[t-1,2];
for (s in 1:(t-1))   
   if(casy[s,1]+casy[s,2] > casy[t,2])
     {soused[t,s]=1;soused[s,t]=1;
      for (c in 1:b){Q[t,c,s]=G}} 
   
   
   else{postihy[t,s]=1/(casy[t,2]-casy[s,1]-casy[s,2])
        ;pomoc[t,s]=1;pomoc[s,t]=1
        for (c in 1:b){Q[t,c,s]=1/(casy[t,2]-casy[s,1]-casy[s,2])}}}

write.table(soused, file = "soused.csv", sep = ",", col.names = NA)
write.table(postihy, file = "postihy.csv", sep = ",", col.names = NA)
write.table(pomoc, file = "pomoc.csv", sep = ",", col.names = NA)
write.table(Q, file = "postihyQ.csv", sep = ",", col.names = NA)
soused
```

