[Tex/LaTex] Custom node in TikZ

tikz-pgf

I'm sorry for the basic question, but I'm new to TikZ and I'm having a lot of trouble just defining a simple node…

I've got the following code:

\begin{tikzpicture}
 \draw (0,0) -- (1,-1) -- (2,0) -- (2,2) -- (0,2) -- (0,0);
\end{tikzpicture}

All I want to do is have the shape defined by the code to be able to use it in a situation like this:

\begin{tikzpicture}[node distance = 2cm, auto]
    % Place nodes
    \node [block] (init) {initialize model};
    \node [cloud, left of=init] (expert) {expert};
    \node [cloud, right of=init] (system) {system};
    \node [block, below of=init] (identify) {identify candidate models};
    \node [block, below of=identify] (evaluate) {evaluate candidate models};
    \node [block, left of=evaluate, node distance=3cm] (update) {update model};
    \node [decision, below of=evaluate] (decide) {is best candidate better?};
    \node [block, below of=decide, node distance=3cm] (stop) {stop};
    % Draw edges
    \path [line] (init) -- (identify);
    \path [line] (identify) -- (evaluate);
    \path [line] (evaluate) -- (decide);
    \path [line] (decide) -| node [near start] {yes} (update);
    \path [line] (update) |- (identify);
    \path [line] (decide) -- node {no}(stop);
    \path [line,dashed] (expert) -- (init);
    \path [line,dashed] (system) -- (init);
    \path [line,dashed] (system) |- (evaluate);
\end{tikzpicture}

… where instead of e.g. "block", I would be able to write "customnode" (or something I've defined myself) and have it appear in the same way, in the same sort of diagram, with text inside.

Many thanks

Best Answer

TikZ has many predefined symbols. The one you're asking about is very similar to the signal symbol in the shapes.symbols library (section 67.4 in the documentation). A cloud symbol is also defined there.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes.symbols}
\begin{document}
\begin{tikzpicture}[
node distance = 3cm, auto,
block/.style={signal, draw, signal to=south}]
\node [block] (init) {initialize model};
\node [cloud,draw, left of=init] (expert) {expert};
\end{tikzpicture}
\end{document}

enter image description here

Related Question