comparison toolboxes/FullBNT-1.0.7/graph/mk_rooted_tree.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 [T, pre, post, cycle] = mk_rooted_tree(G, root)
2 % MK_ROOTED_TREE Make a directed tree pointing away from root
3 % [T, pre, post, cycle] = mk_rooted_tree(G, root)
4
5 n = length(G);
6 T = sparse(n,n); % not the same as T = sparse(n) !
7 directed = 0;
8 [d, pre, post, cycle, f, pred] = dfs(G, root, directed);
9 [junk, pre2] = sort(d);
10 assert(isequal(pre, pre2))
11 [junk, post2] = sort(f);
12 assert(isequal(post, post2));
13 %[d, pre, post, cycle, f, pred] = dfs(G, [], directed);
14 for i=1:length(pred)
15 if pred(i)>0
16 T(pred(i),i)=1;
17 end
18 end
19