Skip to content

Commit

Permalink
Added hgate
Browse files Browse the repository at this point in the history
  • Loading branch information
jluttine committed Sep 7, 2012
1 parent ebc8d96 commit 15f9990
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 20 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Provides the following node styles:

* :code:`factor`

* :code:`plate`

* :code:`gate`

Provides the following commands:

* :code:`\factor`
Expand All @@ -27,6 +31,8 @@ Provides the following commands:

* :code:`\vgate`

* :code:`\hgate`

* :code:`\edge`

* :code:`\factoredge`
Expand Down
7 changes: 6 additions & 1 deletion example.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

\usepackage{tikz}
\usetikzlibrary{bayesnet}
\pgfrealjobname{example} % name of this file
%\pgfrealjobname{example} % name of this file

\title{Graphical Models in Tikz}
\author{Laura Dietz, Jaakko Luttinen}
Expand Down Expand Up @@ -124,3 +124,8 @@
\end{figure}

\end{document}

%%% Local Variables:
%%% mode: tex-pdf
%%% TeX-master: t
%%% End:
4 changes: 2 additions & 2 deletions model_citation_influence.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

% Citation influence model

\beginpgfgraphicnamed{model-citation-influence}
%\beginpgfgraphicnamed{model-citation-influence}
\begin{tikzpicture}

% Layout the variables
Expand Down Expand Up @@ -112,4 +112,4 @@
} {$\forall d \in \mathcal{D}$} ; %

\end{tikzpicture}
\endpgfgraphicnamed
%\endpgfgraphicnamed
4 changes: 2 additions & 2 deletions model_lda.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

% Latent Diriclet allocation model

\beginpgfgraphicnamed{model-lda}
%\beginpgfgraphicnamed{model-lda}
\begin{tikzpicture}[x=1.7cm,y=1.8cm]

% Nodes
Expand Down Expand Up @@ -43,4 +43,4 @@
} {$\forall t \in \mathcal{T}$} ; %

\end{tikzpicture}
\endpgfgraphicnamed
%\endpgfgraphicnamed
4 changes: 2 additions & 2 deletions model_pca.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

% PCA model

\beginpgfgraphicnamed{model-pca}
%\beginpgfgraphicnamed{model-pca}
\begin{tikzpicture}


Expand All @@ -20,4 +20,4 @@
\plate {(x)(y)(w)} {$n=1,\ldots,N$}

\end{tikzpicture}
\endpgfgraphicnamed
%\endpgfgraphicnamed
40 changes: 27 additions & 13 deletions tikzlibrarybayesnet.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@
\tikzstyle{factor} = [rectangle, fill=black,minimum size=5pt, inner
sep=0pt, node distance=0.4, font=\small]

%\tikzstyle{label} += [font=\footnotesize]

% Caption node?
%\tikzstyle{caption} = [node distance=2pt]

\tikzset{plates/.code={\text{Hello world!}}}

% Plate node
\tikzstyle{plate} = [draw, rectangle, rounded corners, fit=#1]
% Constant node
% Invisible wrapper node
\tikzstyle{wrap} = [inner sep=0pt, fit=#1]
% Gate
\tikzstyle{gate} = [draw, rectangle, dashed, fit=#1]
Expand All @@ -61,9 +54,9 @@

\tikzset{>={triangle 45}}

\pgfdeclarelayer{b}
\pgfdeclarelayer{f}
\pgfsetlayers{b,main,f}
%\pgfdeclarelayer{b}
%\pgfdeclarelayer{f}
%\pgfsetlayers{b,main,f}

\newcommand{\factoredge}[4][]{ %
% Connect all nodes #2 to all nodes #4 via all factors #3.
Expand Down Expand Up @@ -106,6 +99,8 @@
} ;%
}

% name, fitlist-left, caption-left, fitlist-right, caption-right,
% inputs
\newcommand{\vgate}[6]{ %
% Wrap the left and right parts
\node[wrap=#2] (#1-left) {}; %
Expand All @@ -122,7 +117,27 @@
% Draw inputs
\foreach \x in {#6} { %
\draw [-*,thick] (\x) -- (#1); %
%\draw [-*,thick] (\x) -- (#1.north); %
} ;%
}

% name, fitlist-top, caption-top, fitlist-bottom, caption-bottom,
% inputs
\newcommand{\hgate}[6]{ %
% Wrap the left and right parts
\node[wrap=#2] (#1-top) {}; %
\node[wrap=#4] (#1-bottom) {}; %
% Draw the gate
\node[gate=(#1-top)(#1-bottom)] (#1) {}; %
% Add captions
\node[caption, above right=of #1.west ] (#1-top-caption)
{#3}; %
\node[caption, below right=of #1.west ] (#1-bottom-caption)
{#5}; %
% Draw middle separation
\draw [-, dashed] (#1.west) -- (#1.east); %
% Draw inputs
\foreach \x in {#6} { %
\draw [-*,thick] (\x) -- (#1); %
} ;%
}

Expand Down Expand Up @@ -284,4 +299,3 @@
% }

% \endinput

0 comments on commit 15f9990

Please sign in to comment.