1

I want to label each vertices of Fano hypergraph with v1,v2, . . . ,v7 but I don't know how to label its Fano hypergraph. This is what I have done :

  \newcommand\FanoPlane[1][1cm]{%
  \begin{tikzpicture}[
     mydot/.style={
     draw,
     circle,
     fill=black,
     inner sep=3pt}
]
 \draw
 (0,0) coordinate (A) --
 (#1,0) coordinate (B) --
 ($ (A)!.5!(B) ! {sin(60)*2} ! 90:(B) $) coordinate (C) -- cycle;
\coordinate (O) at
   (barycentric cs:A=1,B=1,C=1);
\draw (O) circle [radius=#1*1.717/6];
\draw (C) -- ($ (A)!.5!(B) $) coordinate (LC); 
\draw (A) -- ($ (B)!.5!(C) $) coordinate (LA); 
\draw (B) -- ($ (C)!.5!(A) $) coordinate (LB); 
\foreach \Nodo in {A,B,C,O,LC,LA,LB}
\node[mydot] at (\Nodo) {};    
\end{tikzpicture}%
}
\begin{figure}[H]
\centering
\quad\FanoPlane[5cm]
\caption{An example of a hypergraph, with $X= \{ v_1, v_2, ..., v_7 \}$} and $E= \{e_1, e_2, . . ., e_7 \}= \{ \{v_1,v_2,v_3\}, \{v_1,v_4,v_5\}, \{v_1,v_6,v_7\}, \{v_2,v_4,v_6\}, \{v_2,v_5,v_7\},\{v_3,v_4,v_7\}, \{v_3,v_5, v_6\}\}$      \label{fig:figurelabel}
 \end{figure}
user273952
  • 113
  • 3

1 Answers1

2

One option would be to modify the \foreach loop to

\foreach [count=\i] \Nodo/\pos in {A/left,B/right,C/left,O/left,LC/below,LA/right,LB/left}
  \node[mydot,label=\pos:$v_\i$] at (\Nodo) {};

The \foo/\bar syntax lets you have two loop variables. Here, one for the node name, the other for the position of the label relative to the node. count is just what it says, a counter for the number of times the loop has run.

output of code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand\FanoPlane[1][1cm]{%
\begin{tikzpicture}[
  mydot/.style={
     draw,
     circle,
     fill=black,
     inner sep=3pt}
]
 \draw
 (0,0) coordinate (A) --
 (#1,0) coordinate (B) --
 ($ (A)!.5!(B) ! {sin(60)*2} ! 90:(B) $) coordinate (C) -- cycle;
\coordinate (O) at
   (barycentric cs:A=1,B=1,C=1);
\draw (O) circle [radius=#1*1.717/6];
\draw (C) -- ($ (A)!.5!(B) $) coordinate (LC); 
\draw (A) -- ($ (B)!.5!(C) $) coordinate (LA); 
\draw (B) -- ($ (C)!.5!(A) $) coordinate (LB); 
\foreach [count=\i] \Nodo/\pos in {A/left,B/right,C/left,O/left,LC/below,LA/right,LB/left}
  \node[mydot,label=\pos:$v_\i$] at (\Nodo) {};   
\end{tikzpicture}%
}
\begin{document}
\FanoPlane[5cm]
\end{document}
Torbjørn T.
  • 206,688