# Tightly fit a circle around points

When using \node[circle, fit=(A) (B) (C)], the resulting circle is too big and doesn't touch the corners of the C node:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}
\begin{tikzpicture}
\node[draw=blue] (A) at (30:1cm) {A};
\node[draw=blue] (B) at (150:1cm) {B};
\node[draw=blue] (C) at (270:1cm) {C};

\node[circle,draw=red,thick,fit=(A) (B) (C),inner sep=0pt] {};
\end{tikzpicture}
\end{document}


It seems that this is because tikz is actually constructing a rectangle around the nodes to fit, and then drawing a circle outside of it, as can be seen by removing the circle option:

How can I tightly fit a circle outside a set of nodes (possibly more than 3) in Tikz, without calculating the center and size by hand?

• It is really simple to find the smallest rectangle (using max-min of the Cartesian coordinates), but, as far as I know, there is no simple algorithm to find the smallest circle containing set of points. – Kpym Oct 26 '15 at 18:01
• Stumbled upon the same problem. Still very interested in a solution. – raedma Aug 3 '18 at 17:50

With tkz-euclide and \tkzCircumCenter; I left the original fitting node for comparison:

\documentclass{article}
\usepackage{tkz-euclide}
\usetikzlibrary{fit}

\begin{document}

\begin{tikzpicture}
\node[draw=blue] (A) at (30:1cm) {A};
\node[draw=blue] (B) at (150:1cm) {B};
\node[draw=blue] (C) at (270:1cm) {C};

\node[circle,draw=red,thick,fit=(A) (B) (C),inner sep=0pt] {};

\coordinate (a) at (A.north east);
\coordinate (b) at (B.north west);
\coordinate (c) at (C.south east);
\tkzCircumCenter(a,b,c)
\tkzGetPoint{O}
\tkzDrawPoint(O)
\tkzDrawCircle[color=cyan](O,a)
\end{tikzpicture}

\end{document}