3

How could I draw this directed graph using LaTeX?

enter image description here

I know the following code:

\documentclass[12pt]{article}

\usepackage{tikz}

\usetikzlibrary{graphs,graphs.standard}

\tikzgraphsset{declare={polygon_n}{[clique]\foreach\x in\tikzgraphV{\x/}}}

\begin{document}

\begin{center}
\tikz\graph[clockwise, nodes={circle, node distance=4cm, fill=blue, inner sep=1}] 
{ polygon_n[n=5] };
\end{center}

\end{document}

Thanks.

2

If you don't need the rotation you can use subgraph C_n [n=5, counterclockwise], provided by the graphs.standard library to get the basic shape. Then it's just a matter of setting the style of the nodes and edges, as in the example below:

enter image description here

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard}
\begin{document}

\begin{center}
\begin{tikzpicture}
\graph [
  nodes={draw, circle, fill=red!20}, % style of nodes
  edges={-latex}, % style of lines between nodes
  radius=2cm % size of graph
  ] {
    subgraph C_n [n=5, counterclockwise]
  };

\end{tikzpicture}
\end{center}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.