\section{Graphes}

%double tiret dans le texte
\newcommand{\dd}{-{}-}

\subsection{Noeuds}


%création de noeud
\begin{frame}[fragile, t]
\frametitle{Créer des noeuds}

\begin{tikzpicture}
\tikzstyle{element} = [outer sep=0,inner sep=1]
\node[element] (node) at (0,0) {\verb|\node|};
\node[element] (options) at (1.8,0) {\verb|[<options>]|};
\node[element] (nom) at (3.8,0) {\verb|(<nom>)|};
\node[element] (pos) at (6,0) {\verb|at (<X>,<Y>) |};
\node[element] (texte) at (8.2,0) {\verb|{texte};|};

%\draw[decorate, decoration ={brace,raise=4pt}] (node.north west) -- (node.north east) node (nodedef) [midway, above=6pt] {Commande};
\draw[decorate, decoration ={brace,raise=4pt, mirror}, thick , blue] (options.south west) -- (options.south east) node (nodedef) [midway, below=6pt] {\begin{tabular}{c}Options \\du noeud\end{tabular}};

\draw[decorate, decoration ={brace,raise=4pt}, thick, blue] (nom.north west) -- (nom.north east) node (nodedef) [midway, above=6pt] {\begin{tabular}{c}Nom du noeud \\(optionnel)\end{tabular}};
\draw[decorate, decoration ={brace,raise=4pt, mirror}, thick,blue] (pos.south west) -- (pos.south east) node (nodedef) [midway, below=6pt] {Coordonnées};
\draw[decorate, decoration ={brace,raise=4pt}, thick, blue] (texte.north west) -- (texte.north east) node (nodedef) [midway, above=6pt] {\begin{tabular}{c}Texte \\(Obligatoire, \\peut être vide)\end{tabular}};

\end{tikzpicture}

\underline{\Large \textbf{Exemple:}}

\vspace{10pt}

\scriptsize{
\ttfamily
\textbackslash node [] (monNoeud) at (0,0) \{ceci est un noeud\};
}

\vspace{10pt}

\begin{center}
\begin{tikzpicture}
\node [] (monNoeud) at (0,0) {ceci est un noeud};
\end{tikzpicture}
\end{center}

\end{frame}




%Options de noeuds 1
\begin{frame}[fragile, t]
\frametitle{Options de noeuds}

\begin{tikzpicture}
\tikzstyle{element} = [outer sep=0,inner sep=1]
\node[element, text=gray] (node) at (0,0) {\verb|\node |};
\node[element] (options) at (2,0) {\verb|[<options>]|};
\node[element, text=gray] (nom) at (4.3,0) {\verb|(<nom>)|};
\node[element, text=gray] (pos) at (6.6,0) {\verb|at (<X>,<Y>) |};
\node[element, text=gray] (texte) at (9,0) {\verb|{texte};|};
\end{tikzpicture}

\vspace{10pt}

%\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}*{3}{c}@{}}

\begin{tikzpicture}
	\uncover<1->{\node [draw, label={[gray]0:\texttt{[draw]} }]                             (n1) at (0,4) {1}; 	}
	\uncover<2->{\node [draw, circle, label={[gray]0:\texttt{[draw, circle]} }]                     (n2) at (0,3) {2}; }
	\uncover<3->{\node [draw, rounded corners=3pt, label={[gray]0:\texttt{\small \begin{tabular}{l}[draw,\\ rounded corners=3pt]\end{tabular}} }]        (n3) at (0,2) {3};}
	\uncover<4->{\node [draw, red, label={[gray, distance=20pt]0:\texttt{[draw, red]} }]                        (n4) at (0,1) {4};}
	\uncover<5->{\node [draw, text = blue, label={[gray, distance=20pt]0:\texttt{[draw, text=blue ]} }]                (n5) at (0,0) {5};}
	
	\uncover<6->{\node [draw, fill=red!30, label={[gray]0:\texttt{[draw, fill=red!30] }} ]                   (n6) at (5, 4) {6}; }
	\uncover<7->{\node [draw, ultra thick, label={[gray]0:\texttt{[draw, ultra thick] } }]                (n7) at (5,3) {7};}
	\uncover<8->{\node [draw, pattern = north east lines, label={[gray]0:\texttt{\small \begin{tabular}{l}[draw, pattern = \\north east lines] \end{tabular}}}] (n8) at (5,2) {8};}
	\uncover<9->{\node [draw, inner sep=1pt, label={[gray]0:\texttt{\small \begin{tabular}{l}[draw, \\inner sep=1pt]\end{tabular}}}]              (n9) at (5,1) {9};}
	\uncover<10->{\node [draw, minimum height = 30pt, label={[gray]0:\texttt{\small \begin{tabular}{l}[draw, \\minimum height = 30pt]\end{tabular} }}]      (n10) at (5, 0) {10};}
\end{tikzpicture}

\vspace{10pt}


\end{frame}



%astuces supplementaires (noeuds)
\begin{frame}[fragile]
\frametitle{Texte du noeud sur plusieurs lignes}


\vspace{30pt}

{\ttfamily 
\textbackslash node [draw] (monNoeud) at (0,0) \{ 

\qquad \textbackslash  begin\{tabular\}

\qquad \qquad ceci est \textbackslash \textbackslash un noeud 

 \qquad \textbackslash end\{tabular\}  

\};}


\vspace{30pt}

{\centering

\begin{tikzpicture}\node [draw] (monNoeud) at (0,0) {\begin{tabular}{c} ceci est \\ un noeud\end{tabular}}; \end{tikzpicture}

}

\end{frame}


%============================================
% Arcs
%============================================
\subsection{Arcs}

%base
\begin{frame}[fragile, t]

\small{
\ttfamily 
\textbackslash draw[<options>] (<noeud 1>) \dd (<noeud 2>);
}
\vspace{5pt}

\underline{\large \textbf{Exemple : }}
\frametitle{Arcs}
{\color{gray}
\begin{verbatim}
\node [draw, circle] (n1) at (0,0) {n1};
...
\end{verbatim}
}

\begin{verbatim}
	\draw[] (n1) -- (n2);
	\draw[dashed, ->] (n2) -| (n3);
\end{verbatim}
\begin{verbatim}
	\draw[red,  line width=4pt, diamond-stealth] 
	                           (n3) to (n1);
\end{verbatim}

\vspace{5pt}

\begin{center}
\begin{tikzpicture}
	\node [draw, circle] (n1) at (0,0) {n1};
	\node [draw, circle] (n2) at (2,2) {n2};
	\node [draw, circle] (n3) at (4,0) {n3};
	\draw[] (n1) -- (n2);
	\draw[dashed, ->] (n2) -| (n3);
	\draw[red, line width=4pt, diamond-stealth] (n3) to (n1);
\end{tikzpicture}
\end{center}



\end{frame}


%---------------------------------------------
% autre options d'arcs


%options d'arcs

\begin{frame}<handout:1-3>[t]
\input{Examples/exemple_graphe}

\scriptsize{
\ttfamily

\only<2|handout:2>{\textbackslash draw[]  (n11) to[{\color{red}loop, looseness=20}] (n11);}

\only<3|handout:2>{\textbackslash draw[]  (n21) to[{\color{red}loop above, looseness=40}] (n21);}


\only<4|handout:2>{\textbackslash draw[]  (n13) to[{\color{red}loop below, looseness=40}] (n13);}

\only<6|handout:2>{
\textbackslash draw[]  (s1) to[{\color{red}bend left}] (n11);

\textbackslash draw[]  (s1) \dd (n11);
}

\only<8|handout:3>{
\textbackslash draw[{\color{red}bend right}]  (s1) to (n13);

\textbackslash draw[]  (s1) \dd (n13);
}

\only<10|handout:3>{
\textbackslash draw[]  (s1) to[{\color{red}bend left}] (n22);
}
\only<14|handout:3>{
\textbackslash draw[]  (n13) to[{\color{red}bend left}] (n31);
}
\only<15|handout:3>{
\textbackslash draw[]  (n13) to[{\color{red}bend left=10}] (n31);
}

\only<17|handout:3>{
\textbackslash draw[]  (n31) to[{\color{red}out = -10, in = 135}] (s2);

\textbackslash draw[]  (n41) to[{\color{red}out=0, in=90}] (s2);
}
}
\end{frame}


%============================================
% Étiquettes
%============================================

\subsection{Étiquettes}

%les labels
\begin{frame}[fragile]

\frametitle{Étiquettes de noeuds}


\scriptsize{
\ttfamily
	\textbackslash node [draw, {\color{red} label = Étiquette du noeud n1}] (n1) at (0,0) \{\};

	\vspace{10pt}

	\textbackslash node [draw, {\color{red} label = \{[red]45:n2\}}] (n2) at (2,0) \{\};
}
	\vspace{20pt}

\begin{tikzpicture}
	\node [draw, label = Étiquette du noeud n1] (n1) at (0,0) {};
	\node [draw, label ={[red]45:n2}] (n2) at (6,0) {};
	\draw[->] (n1) -- (n2);
\end{tikzpicture}


\end{frame}




\begin{frame}[t]
\frametitle{Étiquettes d'arcs}

\scalebox{0.7}{
\begin{tikzpicture}
\node [draw] (n1) at (-6,4) {n1};
\node [draw] (n2) at (1.5,4) {n2};
\node [draw] (n3) at (-6,-1.5) {n3};
\node [draw] (n4) at (-1,2.5) {n4};

%arc 1-2
\draw [] (n1) -- (n2) node[midway, above=10pt, gray]{[midway, above]} node[midway, above]{L};


%arc 1-3
\draw [] (n1) -- (n3) 
node[gray, left, very near start]{[very near start]} node[very near start]{A} 
node[gray, left, near start]{[near start]} node[near start]{B} 
node[gray, left, near end]{[near end]} node[near end]{C}
node[gray, left, very near end]{[very near end]} node[very near end]{D}
;

%arc 3-2
\draw [bend right = 60] (n3) to node[gray, pos=0.2, below right]{[pos=0.2]}  node[pos=0.2]{F} 
node[gray, pos=0.5, below right]{[pos=0.5]}  node[pos=0.5]{G}  
node[gray, pos=0.7, below right]{[pos=0.7]}  node[pos=0.7]{H} 
(n2);


%arc 1-4
\draw [] (n1) -- (n4) node[sloped, below, gray, pos=0.3]{[sloped]} node[sloped, pos=0.3]{N}  
 node[sloped, above, gray, pos=0.65]{[rotate=-45]} node[rotate=-45, pos=0.65]{M} ;


%arc 4-3
\draw [] (n4) -- (n3) node[pos=0.2, left]{W} node[pos=0.2, left= 10pt, gray]{[left]}
node[pos=0.7, right]{K} node[pos=0.7, right= 10pt, gray]{[right]}
;


%arc 4-2
\draw [] (n4) -- (n2) node[pos=0.3, scale = 2]{X} node[gray, pos=0.3, right=5pt]{[scale=2]};








\end{tikzpicture}
}

\vspace{-15pt}


\scriptsize{
\underline{Avec la commande \dd}
\ttfamily


\textbackslash draw [] (n1) \dd (n2) node[midway, above]\{L\};
}


\underline{Avec la commande to}
\scriptsize{
\ttfamily

\textbackslash draw[bend right = 60] (n3) to 

node[pos=0.2]\{F\} node[pos=0.5]\{G\}  node[pos=0.7]\{H\} 

(n2);

}




\end{frame}


%========================================
% Autres astuces
%========================================


%ancres
\begin{frame}

\frametitle{Ancres}

\begin{tikzpicture}

\node[draw, rounded corners=10pt, very thick, minimum size = 60pt] (n1) at (0,0) {\large noeud n};

\draw[->] (-2, -2) node[below left = -3pt]{n.south west} -- (n1.south west);
\draw[->] (-2, 2) node[above left = -3pt]{n.north west} -- (n1.north west);
\draw[->] (2, -2) node[below right = -3pt]{n.south east} -- (n1.south east);
\draw[->] (2, 2) node[above right = -3pt]{n.north east} -- (n1.north east);

\draw[->] (2, -1) node[right]{n.center} -- (n1.center);
\draw[->] (-2,-1) node[left]{n.text} -- (n1.text);

\draw[->] (2, 1) node[right]{n.30} -- (n1.30);


\draw[->] (0, 2) node[above]{n.north} -- (n1.north);
\draw[->] (0, -2) node[below]{n.south} -- (n1.south);
\draw[->] (2, 0) node[right]{n.east} -- (n1.east);
\draw[->] (-2, 0) node[left]{n.west} -- (n1.west);
\end{tikzpicture}

\end{frame}

%ancres 2
\begin{frame}
\frametitle{Ancres}
\begin{columns}

\column{3cm}
\begin{tikzpicture}

\node[draw, very thick, minimum size = 30] (n1) at (2,-2) {n1};

\node[draw, very thick, minimum size = 30] (n2) at (2,2) {n2};

\node[draw, very thick, minimum size = 30] (n3) at (0,0) {n3};


\draw[] (n1.north west) -- (n2.south east);

\draw[] (n1.north east) -- (n2.south west);

\draw[] (n3.north east) -- (n2.west);
\draw[] (n3.south east) -- (n1.center);



\end{tikzpicture}

\column{6.5cm}

\scriptsize{
\ttfamily
{\textbackslash draw[] (n1.north west) \dd (n2.south east);}

{\textbackslash draw[] (n1.north east) \dd (n2.south west);}

{\textbackslash draw[] (n3.north east) \dd (n2.west);}

{\textbackslash draw[] (n3.south east) \dd (n1.center);}
}

\end{columns}
\end{frame}

