# Change vertex and edge style

I wanted the larger circle to be an ellipse, and the loop on the right to be smaller (as the below drawing shows). Does anyone know how to do it?

this is my .TEX document:

\documentclass[12pt]{article}
\usepackage[brazil]{babel}
\usepackage[utf8]{inputenc}
\usepackage{tikz, tkz-euclide}
\usepackage{amssymb}
\usetikzlibrary{automata, positioning, arrows}

\tikzset{->,
>=stealth,
node distance = 3cm,
every state/.style={thick, fill=gray!10},
initial text = $I$}
\begin{document}

\begin{center}
\begin{tikzpicture}
\node[state, initial,accepting] (Q1) at (0,0) {$\{q_1\}$};
\node[state,accepting] (Q2) at (3,0) {$\{q_1,q_2,q_3\}$};

\draw
(Q1) edge [above] node [] {$a$} (Q2)
(Q2) edge [loop right] node [] {$a$} (Q2);

\end{tikzpicture}
\end{center}

\end{document}


this is the output i got:

Edit: thanks to Zarko's answer (+1), I realized that I had not tried the obvious ellipse style (or shape=ellipse) correctly: I had only tried \node[ellipse, state, ... which doesn't give the expected result because, most probably, state implies the circle shape, thus overriding the ellipse style if used in this order. However, with \usetikzlibrary{shapes.geometric}, \node[state, ellipse, ... allows one to draw a state node with an elliptical shape. Therefore, the easiest way would be:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usetikzlibrary{automata, shapes.geometric}

\begin{document}
\begin{tikzpicture}[
->, >=stealth,
node distance=3cm,
every state/.style={thick, fill=gray!10},
initial text={$I$},
]
\node[state, initial, accepting] (Q1) at (0,0) {$\{q_1\}$};
\node[state, ellipse, accepting] (Q2) at (3,0) {$\{q_1, q_2, q_3\}$};

\draw (Q1) edge [above] node {$a$} (Q2);
\draw (Q2.10) .. controls +(40:3mm) and +(90:2mm) .. ([xshift=3.3mm] Q2.east)
node[right] {$a$} .. controls +(-90:2mm) and +(-40:3mm) .. (Q2.-10);
\end{tikzpicture}
\end{document}


For the loop, I obtained the best results by choosing Bézier control points manually, as in the preceding code.

The rest is my first idea that uses \scalebox and the xscale transformation in order to draw the elliptical state. It's a little bit more complicated, but gives good control over the size and eccentricity of the ellipse.

In order to keep the font shape inside your (Q2) node unchanged, I first horizontally scale the node contents by the inverse of the factor that I use to scale the whole circle-shaped node (0.5 × 2 = 1 → the text shape is unchanged).

\documentclass[tikz,12pt,border=1mm]{standalone}
\usepackage{graphicx} % for \scalebox
\usetikzlibrary{automata}

\begin{document}
\begin{tikzpicture}[
->, >=stealth,
node distance=3cm,
every state/.style={thick, fill=gray!10},
initial text={$I$},
]
\node[state, initial, accepting] (Q1) at (0,0) {$\{q_1\}$};
\node[xscale=2, transform shape, state, accepting] (Q2) at (3,0) {%
\scalebox{0.5}[1]{$\{q_1, q_2, q_3\}$}};

\draw (Q1) edge [above] node {$a$} (Q2);
\draw (Q2.20) .. controls +(45:4mm) and +(90:3mm) .. ([xshift=5mm] Q2.east)
node[right] {$a$} .. controls +(-90:3mm) and +(-45:4mm) .. (Q2.-20);
\end{tikzpicture}
\end{document}


Smaller loop:

\draw (Q2.20) .. controls +(40:3mm) and +(90:2mm) .. ([xshift=3.5mm] Q2.east)
node[right] {$a$} .. controls +(-90:2mm) and +(-40:3mm) .. (Q2.-20);


Here is a simpler way for the loop, but it's a bit further from your drawing (the in and out angles are notably different; if you change them, the arrow will not start from and end at the same points on the node border):

\draw (Q1) edge [above] node {$a$} (Q2)
(Q2) edge [loop right, looseness=4] node {$a$} (Q2);


A variation of the first version of @frougon's answer. By defining state style as ellipse the MWE become more concise and clear:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usetikzlibrary{arrows.meta, automata,
positioning,
quotes,
shapes}

\begin{document}
\begin{tikzpicture}[
> = Stealth,
node distance = 7mm,
every edge/.style = {draw, ->},
every state/.style = {ellipse, draw, thick, fill=gray!15,
minimum size=2em, inner xsep=0pt},
initial text = {$I$},
]
\node (Q1)  [state, initial, accepting] {$\{q_1\}$};
\node (Q2)  [state, accepting,
right=of Q1] {$\{q_1, q_2, q_3\}$};
\draw   (Q1) edge ["$a$"] (Q2)
(Q2) edge [loop right, distance=9mm,"$a$"] (Q2);
\end{tikzpicture}
\end{document}


• Stupid me who had tried \node[ellipse, state, ... but not \node[state, ellipse.... Gasp! :) Thanks for making me realize this. Jun 9 at 23:32