Mercurial > hg > camir-ismir2012
annotate toolboxes/FullBNT-1.0.7/graph/mk_rnd_dag.m @ 0:cc4b1211e677 tip
initial commit to HG from
Changeset:
646 (e263d8a21543) added further path and more save "camirversion.m"
author | Daniel Wolff |
---|---|
date | Fri, 19 Aug 2016 13:07:06 +0200 |
parents | |
children |
rev | line source |
---|---|
Daniel@0 | 1 function [dag, order] = mk_rnd_dag(N, max_fan_in) |
Daniel@0 | 2 % MY_MK_RND_DAG Create a random directed acyclic graph |
Daniel@0 | 3 % |
Daniel@0 | 4 % [dag, order] = my_mk_rnd_dag(N, max_fan_in) |
Daniel@0 | 5 % max_fan_in defaults to N. |
Daniel@0 | 6 % order is the random topological order that was chosen |
Daniel@0 | 7 |
Daniel@0 | 8 % Modified by Sonia Leach 2/25/02 |
Daniel@0 | 9 |
Daniel@0 | 10 if nargin < 2, max_fan_in = N; end |
Daniel@0 | 11 |
Daniel@0 | 12 order = randperm(N); |
Daniel@0 | 13 dag = zeros(N,N); |
Daniel@0 | 14 for i=2:N |
Daniel@0 | 15 j = order(i); |
Daniel@0 | 16 %k = sample_discrete(normalise(ones(1, min(i-1, max_fan_in)))); |
Daniel@0 | 17 k = sample_discrete(normalise(ones(1, min(i-1, max_fan_in)+1))) - 1; % min = 0 (bug fix due to |
Daniel@0 | 18 % Pedrito, 7/28/04) |
Daniel@0 | 19 SS = order(1:i-1); % get Set of possible parentS |
Daniel@0 | 20 p = randperm(length(SS)); % permute order of set |
Daniel@0 | 21 dag(SS(p(1:k)),j) = 1; % take first k in permuted order |
Daniel@0 | 22 |
Daniel@0 | 23 % Kevin had: |
Daniel@0 | 24 %SS = subsets(order(1:i-1), k, k); |
Daniel@0 | 25 %p = sample_discrete(normalise(ones(1, length(SS)))); |
Daniel@0 | 26 %dag(SS{p}, j) = 1; |
Daniel@0 | 27 end |