Mercurial > forge
changeset 9458:e823bd67d070 octave-forge
Fixed computation of strongly connected components
author | mmarzolla |
---|---|
date | Tue, 21 Feb 2012 20:39:41 +0000 |
parents | 1614cd3d4080 |
children | 0d7439781ee5 |
files | main/queueing/inst/qnvisits.m |
diffstat | 1 files changed, 29 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/main/queueing/inst/qnvisits.m Tue Feb 21 20:38:43 2012 +0000 +++ b/main/queueing/inst/qnvisits.m Tue Feb 21 20:39:41 2012 +0000 @@ -282,6 +282,32 @@ %! V = qnvisits(P); %! assert( V, [1 0 1; 0 1 1], 1e-5 ); +%!test +%! C = 2; +%! K = 3; +%! P = zeros(C,K,C,K); +%! P(1,1,1,2) = 1; +%! P(1,2,1,3) = 1; +%! P(1,3,2,2) = 1; +%! P(2,2,1,1) = 1; +%! [V ch] = qnvisits(P); +%! assert( ch, [1 1] ); + +## The following transition probability matrix is not well formed: note +## that there is an outgoing transition from center 1, class 1 but not +## incoming transition. +%!test +%! C = 2; +%! K = 3; +%! P = zeros(C,K,C,K); +%! P(1,1,1,2) = 1; +%! P(1,2,1,3) = 1; +%! P(1,3,2,2) = 1; +%! P(2,2,2,1) = 1; +%! P(2,1,1,2) = 1; +%! [V ch] = qnvisits(P); +%! assert( ch, [1 1] ); + %!demo %! P = [ 0 0.4 0.6 0; \ %! 0.2 0 0.2 0.6; \ @@ -415,7 +441,9 @@ fw = __dfs(GF,n); bw = __dfs(GB,n); r = (fw & bw); - s(r) = c++; + if (any(r)) + s(r) = c++; + endif endif endfor endfunction