From 8070dc963753142bb86c4ed698d91fd623ed28e7 Mon Sep 17 00:00:00 2001 From: ziejd2 Date: Thu, 28 Sep 2017 15:04:40 -0500 Subject: BNW using Octave instead of Matlab. This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning. I am calling this BNW_1.02. It can be accessed at: compbio.uthsc.edu/BNW_1.02 --- sourcecodes/bnt-master/graph/scc.m | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sourcecodes/bnt-master/graph/scc.m (limited to 'sourcecodes/bnt-master/graph/scc.m') diff --git a/sourcecodes/bnt-master/graph/scc.m b/sourcecodes/bnt-master/graph/scc.m new file mode 100644 index 00000000..9a2e8b9d --- /dev/null +++ b/sourcecodes/bnt-master/graph/scc.m @@ -0,0 +1,64 @@ +function [c,v] = scc(a,tol) + +% Finds the strongly connected sets of vertices +% in the DI-rected G-raph of A +% c = 0-1 matrix displaying accessibility +% v = displays the equivalent classes +% +% v(i,j) is the j'th member of the i'th equiv class (0 padded) +% +% http://www.math.wsu.edu/math/faculty/tsat/matlab.html + +[m,n] = size(a); +if m~=n 'Not a Square Matrix', break, end +b=abs(a); o=ones(size(a)); x=zeros(1,n); +msg='The Matrix is Irreducible !'; v='Connected Directed Graph !'; +if (nargin==1) tol=n*eps*norm(a,'inf'); end + +% Create a companion matrix +c = b>tol*o; +if (c==o) + % msg, break + v = 1:length(a); + return +end + + +% Compute accessibility in at most n-step paths +for k=1:n + for j=1:n + for i=1:n + % If index i accesses j, where can you go ? + if c(i,j) > 0 c(i,:) = c(i,:)+c(j,:); end + end + end +end +% Create a 0-1 matrix with the above information +c>zeros(size(a)); c=ans; if (c==o) msg, break, end + +% Identify equivalence classes +d=c.*c'+eye(size(a)); d>zeros(size(a)); d=ans; +v=zeros(size(a)); +for i=1:n find(d(i,:)); ans(n)=0; v(i,:)=ans; end + +% Eliminate displaying of identical rows +i=1; +while(i0 + h(j,:)=v(i,:); + j=j+1; + end +end +v=h; + + + -- cgit 1.4.1