[Tex/LaTex] How to label vertices of a graph with non-empty sets using Tikz Package

graphstikz-pgf

enter image description hereI need to assign non-empty sets (instead of numbers) to the vertices of a graph. This may be called set-labeling of graphs. A graph with vertices having set-labels may be called set-labeled graphs (see the given figure). How can I draw set-labeled graphs using Tikz Package in LaTeX?

Thanks in advance,

Best Answer

I don't know where you got \vertex from, but for a normal TikZ node you need to enclose the entire label in { .. }, because the parser is confused by the comma in the label. So use label={right:$\{x_1,x_2\}$} instead of label=right:$\{x_1,x_2\}$

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \node [circle,fill] (u1) at (45:2) [label={right:$\{x_1,x_2\}$}]{};
\end{tikzpicture}
\end{document}
Related Question