1

We are trying to draw a wheel graph of order 6 on overleaf. We're having a hard time drawing it because it's hard to align the two vertices below the hub. We're just a beginner in coding in latex and our codes are just based on this link: https://www.baeldung.com/cs/latex-drawing-graphs. Our order 7 looks so wide as well.

We would like to ask for any code suggestions for us to draw it where we can also put a label on all nodes including the hub.

What we're doing by the way is about edge deletion of Wheel graph. All helps are highly appreciated. Thanks a lot, guys!

2
  • 1
    Welcome to TeX:SE! Please, show us what you try (in form of small but complete document, which we can compile as it is). BTW, your problem has nothing with Overleas, It is just editor. For tags select packages essential to your problem (for example tikz-pgf, I do not know, what you use).
    – Zarko
    Feb 27 at 5:47
  • Use polar coordinates. Put the hub at (0,0) and the spoke nodes at (360*k/n:2), where n is the number of spokes and k is the spoke number. Note the syntax for polar coordinates is (θ:r).
    – Sandy G
    Feb 27 at 17:52

2 Answers 2

2

TikZ has some pretty good built-in tools for drawing graphs. For a wheel graph you can join a single vertex to a cycle graph:

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard} % <-- Need both libraries. This is not clear in the manual.

\begin{document}

\tikz\graph [nodes={draw, circle}, clockwise, radius=1cm, empty nodes]
  {subgraph A[at={(0,-1)}] -- subgraph C_n[n=7]};

\end{document}

There are many options for changing the appearance of the graph: labels, colors, etc.

0

LaTeX usually has several ways to do a problem. The simplest way is often times through using a package which does a lot of the work for you. The documentation for tkz-berge is here; it has the Wheel graph built in (see page 40), so coding is easier. I've added rotate to the options to allow you to rotate the graph by changing 90 to something else. Once you find the look that you want, Changing \grWheel[RA=15]{7} to \grWheel[RA=15]{6} will get you your other graph, no calculations required. You might want to rotate it to get it to look like you want.

\documentclass[11pt,border=12mm]{standalone}
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=.8,rotate=90]
\GraphInit[vstyle=Shade]
\grWheel[RA=4,prefix=]{7}
\end{tikzpicture}
\end{document}

The code, running in Gummi gives:

enter image description here

The documentation of tkz-berge shows you how to change the style of the vertices, edges, put labels in vertices or outside vertices, etc. The border option in the first line of code can be increased if the picture is too big that part of it gets cut off.

EDIT: I should mention that tkz-graph documentation, here by the same package author explains more about the commands. Changing my code through \GraphInit[vstyle=Normal] gives a more standard graph drawing.

\documentclass[11pt,border=12mm]{standalone}
\usepackage{tkz-berge}
\begin{document}
\begin{tikzpicture}[scale=.8,rotate=90]
\GraphInit[vstyle=Normal]
\grWheel[RA=3,prefix=]{7}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .