Friday 7 June 2013

Alignement of tikz-pictures and tables in subfigures

Alignement of tikz-pictures and tables in subfigures

Basically, I'm trying to explain the depth-first search. I'd like to align my images in the following manner:
 I'd like to put two graphs in each single line, with the corresponding 'table' (representing a stack) on the right side of each one:
There are 14 graphs and 12 tables
The first graph and the last one have no table.
Here's my code:
\documentclass{book}

\usepackage[italian]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{geometry}
\geometry{a4paper,top=2.5cm,bottom=2.5cm,left=2cm,right=2cm}
\usepackage{tikz}
\usepackage{tkz-graph}
\usepackage{multirow}
\usepackage{subcaption} %using this package
\usepackage{array}

\newcommand{\myblue}{blue!80}
\newcommand{\mylgray}{black!15}

% I'd like to put two graphs in each single line, with the corresponding 'table' on the right side of each one.
% There are 14 graphs and 12 tables.
% The first graph and the last one have no table.

\begin{document}

% graph 1, NO table
\begin{tikzpicture}
  \GraphInit[vstyle=Dijkstra]
  \Vertex[L=$v_1$]{A}   
  \Vertex[x=1.4,y=1.2,L=$v_2$]{B}   
  \Vertex[x=1.4,y=-1.2,L=$v_3$]{C}
  \Vertex[x=3.2,y=1.2,L=$v_4$]{D}
  \Vertex[x=3.2,y=-1.2,L=$v_5$]{E}
  \Vertex[x=4.6,y=0,L=$v_6$]{F}   
  \tikzset{EdgeStyle/.style={-}}
  \Edge (A)(B)
  \Edge (A)(C)
  \Edge (B)(D)
  \Edge (C)(E)
  \Edge (B)(E)
  \Edge (D)(F)
  \Edge (E)(F)
\end{tikzpicture}

% graph 2, with the 1st table
\begin{tikzpicture}
  \GraphInit[vstyle=Dijkstra]
  \begin{scope}
    \SetVertexNormal[Shape=circle,FillColor=black!20]
    \Vertex[L=$v_1$]{A}
  \end{scope}
  \Vertex[x=1.4,y=1.2,L=$v_2$]{B}   
  \Vertex[x=1.4,y=-1.2,L=$v_3$]{C}
  \Vertex[x=3.2,y=1.2,L=$v_4$]{D}
  \Vertex[x=3.2,y=-1.2,L=$v_5$]{E}
  \Vertex[x=4.6,y=0,L=$v_6$]{F} 
  \tikzset{EdgeStyle/.style={-}}
  \Edge[color=\mylgray](A)(B)
  \Edge[color=\mylgray](A)(C)
  \Edge[color=\mylgray](B)(D)
  \Edge[color=\mylgray](C)(E)
  \Edge[color=\mylgray](B)(E)
  \Edge[color=\mylgray](D)(F)
  \Edge[color=\mylgray](E)(F)
\end{tikzpicture}

% graph 3, with the 2nd table
\begin{tikzpicture}
  \GraphInit[vstyle=Dijkstra]
  \begin{scope}
    \SetVertexNormal[Shape=circle,FillColor=black!20]
    \Vertex[L=$v_1$]{A}
    \Vertex[x=1.4,y=1.2,L=$v_2$]{B}
  \end{scope}     
  \Vertex[x=1.4,y=-1.2,L=$v_3$]{C}
  \Vertex[x=3.2,y=1.2,L=$v_4$]{D}
  \Vertex[x=3.2,y=-1.2,L=$v_5$]{E}
  \Vertex[x=4.6,y=0,L=$v_6$]{F} 
  \tikzset{EdgeStyle/.style={-}}
  \Edge (A)(B)
  \Edge[color=\mylgray](A)(C)
  \Edge[color=\mylgray](B)(D)
  \Edge[color=\mylgray](C)(E)
  \Edge[color=\mylgray](B)(E)
  \Edge[color=\mylgray](D)(F)
  \Edge[color=\mylgray](E)(F)
\end{tikzpicture}

% graph 4 ...
\begin{tikzpicture}
  \GraphInit[vstyle=Dijkstra]
  \begin{scope}
    \SetVertexNormal[Shape=circle,FillColor=black!20]
    \Vertex[L=$v_1$]{A}
    \Vertex[x=1.4,y=1.2,L=$v_2$]{B}
    \Vertex[x=3.2,y=-1.2,L=$v_5$]{E}
  \end{scope}     
  \Vertex[x=1.4,y=-1.2,L=$v_3$]{C}
  \Vertex[x=3.2,y=1.2,L=$v_4$]{D} 
  \Vertex[x=4.6,y=0,L=$v_6$]{F} 
  \tikzset{EdgeStyle/.style={-}}
  \Edge (A)(B)
  \Edge[color=\mylgray](A)(C)
  \Edge[color=\mylgray](B)(D)
  \Edge[color=\mylgray](C)(E)
  \Edge (B)(E)
  \Edge[color=\mylgray](D)(F

No comments:

Post a Comment