Created
June 18, 2012 18:33
-
-
Save tetsuok/2949886 to your computer and use it in GitHub Desktop.
Figure generator for Centroid Path Decomposition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % See: http://research.preferred.jp/2012/06/centroid-path-decomposition/ | |
| \documentclass[onlymath]{beamer} | |
| \usepackage{amssymb,amsmath} | |
| \usepackage{tikz} | |
| \usetikzlibrary{positioning,shapes,shadows,arrows,fit} | |
| \setbeamertemplate{navigation symbols}{} %no nav symbols | |
| \title{CPD} | |
| \author{} | |
| \date{} | |
| \begin{document} | |
| \pgfdeclarelayer{background} | |
| \pgfdeclarelayer{foreground} | |
| \pgfsetlayers{background,main,foreground} | |
| \begin{frame} | |
| \frametitle{} | |
| \begin{center} | |
| \begin{tikzpicture} | |
| [auto, | |
| vertex/.style={circle,fill=white,draw=black, text=black,minimum size=13pt}, | |
| myedge/.style={->,line width=1.0, shorten <=1pt, shorten >= 1pt}, | |
| centroidnode/.style={circle,line width=1.2,fill=red!30!white,draw=red!70!black}, | |
| centroidpath/.style={->,line width=1.2,draw=red!70!black, shorten <=1pt, shorten >= 1pt}, | |
| branchnode/.style={circle,line width=1.2,fill=green!40!white,draw=green!70!black}] | |
| % Create 1st figure | |
| %%%%%%%%%%%%%%%%%%% | |
| \foreach \id/\x/\y in {0/3/8, 1/0/6, 2/3/6/, 3/6.5/6, 4/0/4, 5/2.2/4, | |
| 6/3.8/4, 7/5.7/4, 8/7.3/4, 9/2.2/2, 10/5/2, 11/6.4/2} { | |
| \node[vertex] (\id) at (\x, \y) {\id}; | |
| } | |
| \foreach \from/\to/\l in {0/1/a, 0/2/b, 0/3/d, 1/4/b, 2/5/a, 2/6/b, 3/7/a, 3/8/c, | |
| 5/9/b, 7/10/a, 7/11/d} { | |
| \draw[myedge] (\from) to node[above=1.5pt,right] {\l} (\to); | |
| } | |
| % Create 2nd figure | |
| %%%%%%%%%%%%%%%%%%% | |
| \onslide<2,3>{ | |
| % centroid path | |
| \foreach \i in {0, 2, 5, 9} { | |
| \node[centroidnode] at (\i) {\i}; | |
| } | |
| \foreach \from/\to in {0/2, 2/5, 5/9} { | |
| \draw [centroidpath] (\from) -- (\to); | |
| } | |
| % branches | |
| \foreach \i in {1, 3, 6} { | |
| \node[branchnode] at (\i) {\i}; | |
| } | |
| } | |
| % Create 3rd figure | |
| %%%%%%%%%%%%%%%%%%% | |
| \begin{pgfonlayer}{background} | |
| \onslide<3->{ | |
| \node [draw=blue,thick,fit=(1) (4)] {}; | |
| \node [draw=magenta!70!white,thick,fit=(3) (7) (8) (10) (11)] {}; | |
| } | |
| \end{pgfonlayer} | |
| % Create 4th figure | |
| %%%%%%%%%%%%%%%%%%% | |
| \onslide<4->{ | |
| \foreach \i in {1, 4, 3, 7, 10} { | |
| \node[centroidnode] at (\i) {\i}; | |
| } | |
| \foreach \from/\to in {1/4, 3/7, 7/10} { | |
| \draw [centroidpath] (\from) -- (\to); | |
| } | |
| } | |
| \end{tikzpicture} | |
| \end{center} | |
| \end{frame} | |
| \end{document} | |
| %%% Local Variables: | |
| %%% mode: TeX-PDF | |
| %%% TeX-master: t | |
| %%% End: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment