diff options
| author | ziejd2 | 2017-09-28 15:04:40 -0500 |
|---|---|---|
| committer | ziejd2 | 2017-09-28 15:04:40 -0500 |
| commit | 8070dc963753142bb86c4ed698d91fd623ed28e7 (patch) | |
| tree | d0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m | |
| parent | 7cc31810d53176e805532b2789955f4eedbce6bb (diff) | |
| download | BNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz | |
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
Diffstat (limited to 'sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m')
| -rw-r--r-- | sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m b/sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m new file mode 100644 index 00000000..d622943d --- /dev/null +++ b/sourcecodes/bnt-master/graph/mk_nbrs_of_digraph_not_vectorized.m @@ -0,0 +1,53 @@ +function [Gs, op, nodes] = mk_nbrs_of_digraph2(G0) +% MK_NBRS_OF_DIGRAPH Make all digraphs that differ from G0 by a single edge deletion, addition or reversal +% [Gs, op, nodes] = mk_nbrs_of_digraph(G0) +% op{i} = 'add', 'del', or 'rev' is the operation used to create the i'th neighbor. +% nodes(i,1:2) are the head and tail of the operated-on arc. + +[I,J] = find(G0); +G0bar = setdiag(~G0, 0); % exclude self loops in graph complement +[Ibar,Jbar] = find(G0bar); +nnbrs = 2*length(I) + length(Ibar); +Gs = cell(1, nnbrs); +op = cell(1, nnbrs); +nodes = zeros(nnbrs, 2); + +nbr = 1; +% all single edge deletions +for e=1:length(I) + i = I(e); j = J(e); + G = G0; + G(i,j) = 0; + Gs{nbr} = G; + op{nbr} = 'del'; + nodes(nbr, :) = [i j]; + nbr = nbr + 1; +end + +% all single edge reversals +for e=1:length(I) + i = I(e); j = J(e); + G = G0; + G(i,j) = 0; + G(j,i) = 1; + Gs{nbr} = G; + op{nbr} = 'rev'; + nodes(nbr, :) = [i j]; + nbr = nbr + 1; +end + +[I,J] = find(~G0); +% all single edge additions +for e=1:length(I) + i = I(e); j = J(e); + G = G0; + if i ~= j % don't add self loops + G(i,j) = 1; + Gs{nbr} = G; + op{nbr} = 'add'; + nodes(nbr, :) = [i j]; + nbr = nbr + 1; + end +end + +assert(nnbrs == nbr-1); |
