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