function [ d ] = damage( A , nodes , quiet) %DAMAGE returns the damage value of nodes % % d = DAMAGE( A ) returns d the vector with the % damage value for each node in A. % % d = DAMAGE( A , nodes ) returns only the damage % values of the nodes specied in the vector nodes. % !! Note that in this case the graph is assumed % to be connected !! % % Last change: 10/2/2005 - Florian Knorn if nargin < 1 || nargin > 4 error('Please input at least the adjacency matrix A'); end if nargin < 3 quiet = false; end if nargin == 1 nodes = []; end d = []; if isempty(nodes) % we must do all the work [G,nodes] = splitintocc(A); for j = 1:length(G) d(nodes{j}) = damage(G{j},nodes{j},[],true); end d = d'; else % calc damage only for some nodes n = length(find(sum(A,2))); if ~n, n = 1; end % little tweak for i = 1:length(nodes); if ~quiet if i==1 fprintf(' '); else progress(i); end end currentnode = nodes(i); A_temp = A; A_temp(currentnode,:) = []; A_temp(:,currentnode) = []; d(i) = n - slcc(A_temp); end if ~quiet fprintf('\b'); end end