function [ s , medset ] = status( D , nodes )
%STATUS  returns the status of a node or a graph
%
%   STATUS( D )  returns the status of a graph that
%      is given by its distance matrix D..
%
%   STATUS( D , nodes ) returns the status of the
%      nodes specified in the  nodes  vector.
%
%   [ s , medset ] = STATUS( D ) additionally returns
%      the median set of the graph.
%
%  Last change:  10/2/2005 - Florian Knorn

if nargin < 1 || nargin > 2
	error('Please input at least the distance matrix D');
end
if isnan( D )
	error('How can D be of type LOGICAL ? Adjacency matrix ?');
end
if nargin == 2
	if nargout == 2
		error('Median set only returned if no nodes specified');
	end
	n = length(nodes);
else
	n = 0;
end

if n
	s = sum(D(:,nodes),2);
else
	s_all = sum(D,2);
	s = min(s_all);
	medset = find(s_all==s);
end