function [ e , center ] = excen( D , nodes )
%EXCEN  returns the excentricity of a node or radius of a graph
%
%   EXCEN( D )  returns the radius (or minimal excentricity)
%      of a graph that is given by its distance matrix D.
%
%   EXCEN( D , nodes ) returns the excentricity of the nodes
%      specified in the  nodes  vector.
%
%   [ e , center ] = EXCEN( D ) additionally returns the 
%      center 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 islogical( D )
	error('How can D be of type LOGICAL ? Adjacency matrix ?');
end
if nargin == 2
	if nargout == 2
		error('Center set only returned if no nodes specified');
	end
	n = length(nodes);
else
	n = 0;
end

if n % node-mode
	e = max(D([nodes],:),[],2);
else % graph-mode
	e_all = max(D,[],2);
	e = min(e_all);
	center = find(e_all==e);
end