# How to draw a graph in tikz with emoticons?

I would like to draw a graph and some emoticons with it using tikz in latex as shown in the picture below.

N.B. I am doing a presentation in beamer and the meaning of the picture is that the triangle agent is happy when he/she chooses the corresponding circle product.

I found this question that can help me a little but not completely. How to draw a collection of small bipartite graphs in latex?

Here is my code and what I tired. I used these two codes 1 and 2:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usepackage{marvosym}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\newcommand{\smiley}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-145:0.9mm) arc (-120:-60:1.5mm);
}
}

\newcommand{\frownie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-145:0.9mm) arc (120:60:1.5mm);
}
}

\newcommand{\neutranie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw (-135:0.9mm) -- (-45:0.9mm);
}
}
\usetikzlibrary{arrows,chains,matrix,positioning,scopes}
%
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle, execute at end node=$]
%
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em, column sep=3em]
{  \smiley\; A1 & A2 \\
\smiley\; B1 & B2 \\
\neutranie\; C1 & C2 \\
};
{ [start chain] \chainin (m-1-1);
\chainin (m-1-2);
}
{ [start chain] \chainin (m-2-1);
\chainin (m-2-2);
}
\end{tikzpicture}
\end{document}


And I get this picture:

• What exactly are the issues you are having trouble with? Do you want to create emoticons with TikZ or use emoticons from a font? I assume that the arrows and shapes you can do with the other linked answer. We have some questions that deal with emoticons: Something between \frownie and \smiley and Smileys in LaTeX. – Alan Munn May 13 '15 at 16:11
• I can't draw triangle and circle like the picture I used. – Jika May 13 '15 at 16:19

I'm not sure this is what you want. Probably you can automatise the arrows to be drawn only in certain cases but it's not worth it that much if you need to do it this once.

Some notes:

• arrows is deprecated, use arrows.meta. The definitions for the arrow tips have changed too. Check the Tikz manual (v 3.0.0).
• It's better to use \tikzset than \tikzstyle, see the question Should \tikzset or \tikzstyle be used to define TikZ styles?
• You don't need a chain, you can reference the elements of a matrix by using its name and the rows and columns. For example, if your matrix is named (m), then you can reference a "cell" in the first column and the second row by saying (m-2-1).

## Code

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\usepackage{marvosym}

\usetikzlibrary{arrows.meta,chains,matrix,positioning,scopes}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\newcommand{\smiley}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-145:0.9mm) arc (-120:-60:1.5mm);
}
}

\newcommand{\frownie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-145:0.9mm) arc (120:60:1.5mm);
}
}

\newcommand{\neutranie}{\tikz[baseline=-0.75ex,black]{
\draw circle (2mm);
\node[fill,circle,inner sep=0.5pt] (left eye) at (135:0.8mm) {};
\node[fill,circle,inner sep=0.5pt] (right eye) at (45:0.8mm) {};
\draw[-] (-135:0.9mm) -- (-45:0.9mm);
}
}

\newcommand{\mytri}{\tikz[baseline=.2em,black]{
\draw[fill=white] (0,0) --++ (8pt,0) --++ (-4pt,10pt) -- cycle;
}
}

\newcommand{\mycir}{\tikz[baseline=-0.75ex,black]{
\draw[fill=white] circle (2mm);
}
}

\begin{document}
\begin{tikzpicture}[->, >={Stealth[round]}]
\matrix (m) [matrix of math nodes,row sep=1em, column sep=2em]
{
\smiley\;    \mytri & \mycir & \smiley\;    \mytri & \mycir \\
\frownie\;   \mytri & \mycir & \neutranie\;   \mytri & \mycir \\
\neutranie\; \mytri & \mycir & \frownie\; \mytri & \mycir \\
};

\draw (m-1-1) -- (m-1-2);
\draw (m-2-1) -- (m-2-2);
\draw (m-1-3) -- (m-1-4);
\draw (m-3-3) -- (m-3-4);

\end{tikzpicture}
\end{document}