[Tex/LaTex] Drawing simple graph pattern with Tikz

tikz-pgf

I've been using LaTeX since three years, but I've always avoided the Tikz package for drawing. Now I am writing my degree thesis and I'm forced to use it to achieve a better result. The problem is just I don't have time right now to start a deep walkthrough.

I have to draw these simple patterns of graphs: a triangle and a complete bipartite graph (see pictures below). I found the sample code of a simple triangle graph on the web and I tried to rearrange nodes using relative positioning, but the result was not quite good. This is my attempt.

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
        thick,main node/.style={circle,fill=blue!20,draw,minimum size=1cm,inner sep=0pt]}]

    \node[main node] (1) {$1$};
    \node[main node] (2) [below left of=1]  {$2$};
    \node[main node] (3) [below right of=1] {$3$};

    \path[-]
    (1) edge node {} (2)
        edge node {} (3)
    (2) edge node {} (1)
        edge node {} (3)
    (3) edge node {} (1)
        edge node {} (2);
\end{tikzpicture}

Could you please give me any help to improve this result?

Thank you.

Graph pattern

Best Answer

Well, we answer many questions with "Do it for me!" Why not this one!

TikZ mafia here won't forgive people having no time to learn tikz;). The code you got from elsewhere makes wrong use of below of. This is how it is used with positioning library.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\tikzset{main node/.style={circle,fill=blue!20,draw,minimum size=1cm,inner sep=0pt},
            }
\begin{document}
  \begin{tikzpicture}
    \node[main node] (1) {$1$};
    \node[main node] (2) [below left = 2.3cm and 1.5cm of 1]  {$2$};
    \node[main node] (3) [below right = 2.3cm and 1.5cm of 1] {$3$};

    \path[draw,thick]
    (1) edge node {} (2)
    (2) edge node {} (3)
    (3) edge node {} (1);
    %%
    \begin{scope}[xshift=4cm]
    \node[main node] (1) {$1$};
    \node[main node] (2) [right = 2cm  of 1]  {$2$};
    \node[main node] (3) [below = 2cm  of 1] {$3$};
    \node[main node] (4) [right = 2cm  of 3] {$4$};

    \path[draw,thick]
    (1) edge node {} (2)
    (1) edge node {} (4)
    (3) edge node {} (2)
    (3) edge node {} (4)
    ;
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Related Question