TransWikia.com

How to draw a cycle graph with the help of Tikzit?

TeX - LaTeX Asked by licheng on July 7, 2021

I wanted to try using "Tikzit" to create a cycle graph. But I have a little trouble. Software download link

It may be easy to use the existing tikz code.https://texample.net/tikz/examples/cycle/

% A simple cycle
% Author : Jerome Tremblay
documentclass{article}
usepackage{tikz}
begin{document}
begin{tikzpicture}

def n {5}
def radius {3cm}
def margin {6} % margin in angles, depends on the radius

foreach s in {1,...,n}
{
  node[draw, circle] at ({360/n * (s - 1)}:radius) {$s$};
  draw[-, >=latex] ({360/n * (s -1)+margin}:radius) 
    arc ({360/n * (s - 1)+margin}:{360/n * (s)-margin}:radius);
}
end{tikzpicture}
end{document}

enter image description here

When I want to use Tikzit software, it seems difficult to draw above graph.

The key lies in the location of the vertex and the setting of the curvature of the curve, which is very difficult for me. Don’t know how to adjust them.

enter image description here

The following codes come from this software.

documentclass{article}
usepackage{tikz}
usetikzlibrary{backgrounds}

usetikzlibrary{arrows}
usetikzlibrary{shapes,shapes.geometric,shapes.misc}

% these are dummy properties used by TikZiT, but ignored by LaTex
pgfkeys{/tikz/tikzit fill/.initial=0}
pgfkeys{/tikz/tikzit draw/.initial=0}
pgfkeys{/tikz/tikzit shape/.initial=0}
pgfkeys{/tikz/tikzit category/.initial=0}

% standard layers used in .tikz files
pgfdeclarelayer{edgelayer}
pgfdeclarelayer{nodelayer}
pgfsetlayers{background,edgelayer,nodelayer,main}

% style for blank nodes
tikzstyle{none}=[inner sep=0mm]

% Node styles
tikzstyle{white_node}=[fill=white, draw=black, shape=circle]
tikzstyle{blackedge}=[-, draw=black]

begin{document}
    begin{tikzpicture}
        begin{pgfonlayer}{nodelayer}
            node [style={white_node}] (0) at (5, 6) {};
            node [style={white_node}] (1) at (7, 4) {};
            node [style={white_node}] (2) at (5, 2) {};
            node [style={white_node}] (3) at (3, 3) {};
            node [style={white_node}] (4) at (3, 5) {};
        end{pgfonlayer}
        begin{pgfonlayer}{edgelayer}
            draw [style=blackedge, bend left] (0) to (1);
            draw [style=blackedge, bend left] (1) to (2);
            draw [style=blackedge, bend right=330] (2) to (3);
            draw [style=blackedge, bend left=45, looseness=0.75] (3) to (4);
            draw [style=blackedge, bend left] (4) to (0);
        end{pgfonlayer}
    end{tikzpicture}
end{document}

Edit: After a reminder from SebGlav , my question can actually be equivalent to this:

How to use TikZ code to do that circle graph with proper edges?

The circle is only part of my drawing, in fact I want to draw the following figure.
enter image description here

One Answer

Here is my simple solution.

enter image description here

documentclass[tikz,border=5mm]{standalone}
begin{document}
begin{tikzpicture}[thick]
defr{2} 
draw (0,0) circle(r)
(0,0)--(90:r)
(0,0)--(150:r)
(0,0)--(-30:r);

foreach point in {(0,0),(90:r),(150:r),(210:r),(30:r),(-30:r),(-90:r),(150:r/3),(150:2*r/3),(-30:r/2),(90:r/2)}
draw[teal,fill=white] point circle(.1);

path
(0,0) node[below=1mm]{$omega$}
(-30:r) node[below right]{$u$}
(-30:r/2) node[above=1mm]{$P'$}
(90:r) node[above=1mm]{$z$}
(90:r/2) node[left=1mm]{$P$}
(150:r) node[left=1mm]{$y$}
(150:2*r/3) node[below=1mm]{$x$}
(-90:r) node[below=1mm]{$C$}
;
end{tikzpicture}
end{document}

Correct answer by Black Mild on July 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP