Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/assignEdgeNums.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function [edge_id, nedges] = assignEdgeNums(adj_mat) |
matthiasm@8 | 2 % give each edge a unique number |
matthiasm@8 | 3 % we number (i,j) for j>i first, in row, column order. |
matthiasm@8 | 4 % Then we number the reverse links |
matthiasm@8 | 5 |
matthiasm@8 | 6 nnodes = length(adj_mat); |
matthiasm@8 | 7 edge_id = zeros(nnodes); |
matthiasm@8 | 8 e = 1; |
matthiasm@8 | 9 for i=1:nnodes |
matthiasm@8 | 10 for j=i+1:nnodes |
matthiasm@8 | 11 if adj_mat(i,j) |
matthiasm@8 | 12 edge_id(i,j) = e; |
matthiasm@8 | 13 e = e+1; |
matthiasm@8 | 14 end |
matthiasm@8 | 15 end |
matthiasm@8 | 16 end |
matthiasm@8 | 17 |
matthiasm@8 | 18 nedges = e-1; |
matthiasm@8 | 19 tmp = edge_id; |
matthiasm@8 | 20 ndx = find(tmp); |
matthiasm@8 | 21 tmp(ndx) = tmp(ndx)+nedges; |
matthiasm@8 | 22 edge_id = edge_id + triu(tmp)'; |
matthiasm@8 | 23 |
matthiasm@8 | 24 |
matthiasm@8 | 25 if 0 |
matthiasm@8 | 26 ndx = find(adj_mat); |
matthiasm@8 | 27 nedges = length(ndx); |
matthiasm@8 | 28 nnodes = length(adj_mat); |
matthiasm@8 | 29 edge_id = zeros(1, nnodes*nnodes); |
matthiasm@8 | 30 edge_id(ndx) = 1:nedges; |
matthiasm@8 | 31 edge_id = reshape(edge_id, nnodes, nnodes); |
matthiasm@8 | 32 end |