Is there an wasy way to program in Tikz something like the one in the image?
It is not too difficult to draw such a thing in loops. pic
s may further help to avoid repetition. I did not understand your numbering scheme so you will have to modify evaluate=\Y as \Z using {int(mod(33-\Y-\X,5)+1)}
to match your prescription.
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric,calc}
\newcounter{hexi}
\begin{document}
\begin{tikzpicture}[pics/hexi/.style={code={\stepcounter{hexi}
\node[draw,regular polygon,regular polygon sides=6,minimum width=2cm]
(hexi-\number\value{hexi}) {#1};
\foreach \Corner in {1,...,6}
{\ifodd\Corner
\draw[fill=black] (hexi-\number\value{hexi}.corner \Corner) circle[radius=1.5pt];
\else
\draw[fill=white] (hexi-\number\value{hexi}.corner \Corner) circle[radius=1.5pt];
\fi}
}},bullet/.style={circle,fill,inner sep=0.5pt}]
%
\clip (0,1) rectangle (9.8,6.5);
% draw the hexagons
\path foreach \X in {1,...,6} {
foreach \Y [evaluate=\Y as \Z using {int(mod(33-\Y-\X,5)+1)}] in {1,...,4} { \ifodd\X
({\X*(1+cos(60))},{\Y*(2*sin(60))})
\else
({\X*(1+cos(60))},{\Y*(2*sin(60))-sin(60)})
\fi pic{hexi=\Z}}};
% draw the blue arrows
\foreach \X in {7,9,10,11,14}
{\foreach \Y [remember=\Y as \LastY (initially 6)]in {1,...,6}
{\draw[blue,-latex,shorten >=2pt,shorten <=2pt]
($(hexi-\X.corner \LastY)!0.1!(hexi-\X.center)$)
-- ($(hexi-\X.corner \Y)!0.1!(hexi-\X.center)$);}}
% draw the red contour
\draw[red] ([yshift=-0.3cm]hexi-3.center) node[bullet]{}
-- ([yshift=-0.3cm]hexi-6.center) node[bullet]{}
-- ([yshift=-0.3cm]hexi-18.center) node[bullet]{}
-- ([yshift=-0.3cm]hexi-16.center) node[bullet]{} -- cycle;
\end{tikzpicture}
\end{document}
Your code is far from optimal, so I'll not reproduce it here. I only show you how to add the blue arrow next to an edge, as you asked, by creating a style with arrows
.
EDIT: I added also a closepath code
to with arrows
style in a way to be able to use it with regular polygon
nodes (shown already in the @marmot's answer).
\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{decorations.pathreplacing,calc,shapes.geometric}
\tikzstyle{with arrows}=[
postaction={decorate,
decoration={show path construction,
lineto code={
\draw [blue,-latex] ($(\tikzinputsegmentfirst)!1mm!45:(\tikzinputsegmentlast)$) -- ($(\tikzinputsegmentlast)!1mm!-45:(\tikzinputsegmentfirst)$);
},
closepath code={
\draw [blue,-latex] ($(\tikzinputsegmentfirst)!1mm!45:(\tikzinputsegmentlast)$) -- ($(\tikzinputsegmentlast)!1mm!-45:(\tikzinputsegmentfirst)$);
}
}
}
]
\begin{document}
\begin{tikzpicture}
\draw[with arrows] (0,0) -- (1,1) node[scale=2]{.} -- (2,0);
\node[regular polygon,regular polygon sides=6,minimum width=2cm,draw,with arrows] at (3,1) {1};
\end{tikzpicture}
\end{document}