2

I have this complete subgraph:

\begin{tikzpicture}
  \graph[nodes={draw, circle}, n=5, clockwise, radius=2cm]
  { subgraph K_n; };
\end{tikzpicture}

If I wish to somehow distinguish vertex number 3, I can consult this question

\begin{tikzpicture}
  \graph[nodes={draw, circle}, n=5, clockwise, radius=2cm]
  { 1; 2; 3[fill=gray]; 4; 5; subgraph K_n; };
\end{tikzpicture}

Now, suppose that instead of highlighting it, I wish to change it contents. For example, suppose I wish to change its label to the greek letter alpha, instead of the current 3. Something like this will not work:

\begin{tikzpicture}
  \graph[nodes={draw, circle}, n=5, clockwise, radius=2cm]
  { 1; 2; 3[contents=$\alpha$]; 4; 5; subgraph K_n; };
\end{tikzpicture}

Any other way to achieve this fairly simple task, or, in general, label the vertices of K_n in a custom way? Of course, I can manually draw K_5 and label the nodes, but tikz graphs.standard library is nice and I wish to use it in order to avoid manual calculations.

Update

I have a found a way to label vertex 3 with a different number.

\begin{tikzpicture}
  \graph[nodes={draw, circle}, n=5, clockwise, radius=2cm]
  { subgraph K_n [V={1,2,7,4,5}];};
\end{tikzpicture}

This also works if instead of 7 I write a or FOO (in the last case it makes the node a bit larger). I can even put there 7/2.

What I can't put there instead of 7 is 7,2 (even inside {...}) or \alpha or $\alpha$ or {$\alpha$}. Trying any of these simply destroy the graph.

  • Please complete your code so we can copy-paste-compile it rather than having to guess the packages and libraries you are using. – cfr Nov 8 '15 at 1:22
5

Not sure if this helps or not. It does not use the subgraph K_n but instead specifies the nodes manually so that their contents can be specified as desired. clique is used to draw the connections automatically, partially emulating the functionality provided by the subgraph.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphs,graphs.standard}
\begin{document}
\begin{tikzpicture}
  \graph[nodes={draw, circle}, clique, n=5, clockwise, radius=2cm]
  {
    1/"$\alpha$", 2/"7,2", 3/"$x^2$", 4/"9,8,4", 5/"$\zeta$"
  };
\end{tikzpicture}
\end{document}

alternate names in circle

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.