comparison toolboxes/FullBNT-1.0.7/graph/mk_rnd_dag.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [dag, order] = mk_rnd_dag(N, max_fan_in)
2 % MY_MK_RND_DAG Create a random directed acyclic graph
3 %
4 % [dag, order] = my_mk_rnd_dag(N, max_fan_in)
5 % max_fan_in defaults to N.
6 % order is the random topological order that was chosen
7
8 % Modified by Sonia Leach 2/25/02
9
10 if nargin < 2, max_fan_in = N; end
11
12 order = randperm(N);
13 dag = zeros(N,N);
14 for i=2:N
15 j = order(i);
16 %k = sample_discrete(normalise(ones(1, min(i-1, max_fan_in))));
17 k = sample_discrete(normalise(ones(1, min(i-1, max_fan_in)+1))) - 1; % min = 0 (bug fix due to
18 % Pedrito, 7/28/04)
19 SS = order(1:i-1); % get Set of possible parentS
20 p = randperm(length(SS)); % permute order of set
21 dag(SS(p(1:k)),j) = 1; % take first k in permuted order
22
23 % Kevin had:
24 %SS = subsets(order(1:i-1), k, k);
25 %p = sample_discrete(normalise(ones(1, length(SS))));
26 %dag(SS{p}, j) = 1;
27 end