Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
% function dist = node2distance(node,maxset,varargin)
% node is the input network
% dist is the distance matrix
% maxset is the maximum distance
% disconnected cluster distance is set to maxdist+1 or maxset
function [dist maxdis] = node2distance(node, maxset, varargin)
[sy,N] = size(node);
dist = zeros(N,N);
for vertex = 1:N
list = node(vertex).link;
b = zeros(N,1);
vec = zeros(N,1);
vec(vertex) = 1;
b = vec;
A = adjacency(node);
endtest = 1;
bold = b;
index = 0;
while (endtest ~= -1)&(index < N)
index = index + 1;
bnew = bold + A*bold;
dif = bnew - bold;
for loop = 1:N
if (bnew(loop) >0)&(bold(loop) == 0)
dist(vertex,loop) = index;
end
end
endtest = where(bnew,0);
bold = bnew;
end
end
maxdis = max(max(dist));
if nargin == 2
setmax = maxset;
else
setmax = maxdis+1;
end
for yloop = 1:N-1
for xloop = yloop+1:N
if dist(yloop,xloop) == 0
%dist(yloop,xloop) = -1;
%dist(xloop,yloop) = -1;
dist(yloop,xloop) = setmax;
dist(xloop,yloop) = setmax;
end
end
end