comparison toolboxes/FullBNT-1.0.7/graph/assignEdgeNums.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 [edge_id, nedges] = assignEdgeNums(adj_mat)
2 % give each edge a unique number
3 % we number (i,j) for j>i first, in row, column order.
4 % Then we number the reverse links
5
6 nnodes = length(adj_mat);
7 edge_id = zeros(nnodes);
8 e = 1;
9 for i=1:nnodes
10 for j=i+1:nnodes
11 if adj_mat(i,j)
12 edge_id(i,j) = e;
13 e = e+1;
14 end
15 end
16 end
17
18 nedges = e-1;
19 tmp = edge_id;
20 ndx = find(tmp);
21 tmp(ndx) = tmp(ndx)+nedges;
22 edge_id = edge_id + triu(tmp)';
23
24
25 if 0
26 ndx = find(adj_mat);
27 nedges = length(ndx);
28 nnodes = length(adj_mat);
29 edge_id = zeros(1, nnodes*nnodes);
30 edge_id(ndx) = 1:nedges;
31 edge_id = reshape(edge_id, nnodes, nnodes);
32 end