image - Graph mining matlab -
i have written matlab code image analysis searches clusters in image , builds adjacency matrix clusters, discribing clusters touiching eachother in image.
i can use adjacency matrix derive graph.
for completion of algorithm have mine graph nodes of maximum degree of 2 node index either higher of neigbor (when degree 1) or between indexes of 2 neighbors.
basically in image here:
i need in matlab , important know try available adjacency matrix looking like:
1 2 3 4
1 0 0 1 1
2 0 0 0 1
3 1 0 0 1
4 1 1 1 0
probably quite simple don't see solution...
here's attempt @ this:
%# adjacency matrix m = [0 0 1 1; 0 0 0 1; 1 0 0 1; 1 1 1 0]; %# degree == 1 n = find(sum(m,2) == 1); %# nodes degree(n)==1 nodes1 = n(n>find(m(n,:))); %# nodes index higher of neigbor %# degree == 2 n = find(sum(m,2) == 2); %# nodes degree(n)==2 nb = zeros(numel(n),2); i=1:numel(n) nb(i,:) = find( m(n(i),:) ); %# two-neighbors of node n(i) end %#nb = sort(nb,2); nodes2 = n(nb(:,1)<n & n<nb(:,2)); %# nodes index between indices of 2 neighbors %# combine both results nodes = unique([nodes1(:);nodes2(:)]);
Comments
Post a Comment