# Flowchart where the nodes are pspictures

I want to create a flowchart, in which every node is itself a pspicture (with nodes and arrows), and there are arrows between the pspictures themselves. Here is an example (which looks bad because I had to manually place the text and the arrows):

Currently, I am creating the arrows manually, but I am sure this is not the right way to do it. Here is my current code:

\documentclass[11pt,,section]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
%\usepackage[a4paper]{geometry}
%\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}

\usepackage[crop=on]{auto-pst-pdf}
\usepackage{pstricks,pst-node,pst-tree}
\usepackage{graphics,graphicx}

%

\newcommand{\action}[1] {
\rput(-1.5,-.5){#1}
}

\newcommand{\goleft}[1] {
\pcline[linecolor=black]{->}(-4,-0.5)(-5,-1.5)\bput(.5){\emph{#1}}
}
\newcommand{\godown}[1] {
\pcline[linecolor=black]{->}(-1.5,-0.5)(-1.5,-1.5)\aput(.5){\emph{#1}}
}
\newcommand{\goright}[1] {
\pcline[linecolor=black]{->}(1.5,-0.5)(2.5,-1.5)\aput(.5){\emph{#1}}
}

%

\newcommand{\agent}[1]{\circlenode[linecolor=white]{#1}{\textcolor{blue}{#1}}}
\newcommand{\piece}[1]{\dianode[linecolor=white]{#1}{\textcolor{blue}{#1}}}
\newcommand{\like}[2]{\ncline[linecolor=green]{->}{#1}{#2}}
\newcommand{\likenext}[2]{\ncline[linecolor=gray,linestyle=dashed]{->}{#1}{#2}}
\newcommand{\likemaybe}[2]{\ncline[linecolor=gray,linestyle=dashed]{->}{#1}{#2}}
\newcommand{\threeagents}{
\agent{A}  \agent{B}  \agent{C}

\vspace{7mm}

\piece{1}  \piece{2}  \piece{3}
}
\newcommand{\fouragents}{
\agent{A} & \agent{B} & \agent{C} & \agent{D}  \\
\piece{1} & \piece{2} & \piece{3} & \piece{4}
}
\psset{colsep=0.5cm,rowsep=1cm}

\begin{document}

\begin{psmatrix}[colsep=0,rowsep=1.7]
\makebox[5cm] {
}
&
\makebox[5cm] {
Start
\goleft{B,C,D have 3 neighbors}
\godown{2 neighbors}
\goright{1 neighbor}
}
&
\makebox[5cm] {
}

\\

\begin{psmatrix}[colsep=0cm]
\fouragents

\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{2}
\like{C}{3}
\like{D}{4}

\end{psmatrix}
\action{Done}
&
\begin{psmatrix}[colsep=0cm]
\fouragents

\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{1}
\like{C}{4}
\like{D}{4}
\end{psmatrix}

\goleft{}
\godown{}
&
\begin{psmatrix}[colsep=0cm]
\fouragents

\like{A}{1}\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{4}
\like{C}{4}
\like{D}{4}
\end{psmatrix}
\\

\begin{psmatrix}[colsep=0cm]
\fouragents

\like{A}{2}\like{A}{3}\like{A}{4}
\like{B}{1}\like{B}{2}
\like{C}{4}
\like{D}{4}
\end{psmatrix}
&

\begin{psmatrix}[colsep=0cm]
\fouragents

\like{A}{2}\like{A}{3}
\like{B}{1}\like{B}{2}
\like{C}{4}\like{C}{2}
\like{D}{4}
\end{psmatrix}
&
%%%

\end{psmatrix}
\\
\\

\end{document}


I am trying to create arrows from the "start" psmatrix to each of the psmatrix-es in the next row. But this doesn't look good.

Here is an example which shows that you can work with symbolic names for the cells:

\documentclass[11pt,,section]{article}

\usepackage[crop=on]{auto-pst-pdf}
\usepackage{pst-node}
\def\Line{\ncline[arrows=->,linecolor=green]}

\begin{document}

\begin{psmatrix}[colsep=3cm,rowsep=1.7]
& [name=start] Start & \\[1cm]
[name=Aleft]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\psspan{3}Done
\Line{1,1}{2,1}\Line{1,2}{2,2}\Line{1,3}{2,3}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
& [name=Acenter]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\Line{1,1}{2,1}\Line{1,2}{2,1}\Line{1,3}{2,4}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
& [name=Aright]
\begin{psmatrix}[colsep=0.5cm,rowsep=0mm]
A & B & C & D \\[12mm]
1 & 2 & 3 & 4\\
\Line{1,1}{2,1}\Line{1,2}{2,4}\Line{1,3}{2,4}\Line{1,4}{2,4}
\Line{1,1}{2,2}\Line{1,1}{2,3}\Line{1,1}{2,4}
\end{psmatrix}
\end{psmatrix}
\ncline[nodesepA=2mm,offsetB=-15mm]{start}{Aleft}\nbput{B,C,D have 3 neighbors}
\ncline[nodesep=2mm]{start}{Acenter}\ncput*{2 neighbors}
\ncline[nodesepA=2mm,offsetB=10mm]{start}{Aright}\naput{1 neighbor}

\end{document}


• I tried this and got two empty pages. But the problem was solved after I moved the last three "\ncline" statements above the last "\end{psmatrix}". Thanks! – Erel Segal-Halevi Sep 8 '15 at 11:38
• ah yes, I didn't ude auto-pst-pdf. The reason why it works in both ways. I always use xelatex – user2478 Sep 8 '15 at 13:00

I simplified your code. One psmatrix environment is enough. Is that like you want?

\documentclass[11pt,,section]{article}
\usepackage{pst-node,pst-tree}
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{graphicx}

\newcommand{\agent}[1]{\circlenode[linecolor=white]{#1}{{#1}}}%
\newcommand{\like}[2]{\ncline[linecolor=green]{->}{#1}{#2}}

\begin{document}\color{blue}
\psset{arrows=->, arrowinset=0.25, colsep=0.75cm, nodesep=2pt}
\begin{psmatrix}
& \agent{Start}\\
\agent{A} & & \agent{E}\\
\agent{B} & [mnode=oval, linecolor=white]\agent{C}\hspace{1.5cm}\agent{D} & \agent{F}
\ncline{Start}{A}
\ncline{Start}{3,2}
\ncline{Start}{E}
\psset{linecolor=green}
\ncline{A}{B}
\ncline{F}{E}
\ncline{C}{D}
\end{psmatrix}

\end{document}


• Actually my use-case is more complicated (I tried to simplify it but probably over-simplified), because in every frame there are the same letters: A,B,C,D and more. So I cannot just send arrows from Start to different letters. – Erel Segal-Halevi Sep 7 '15 at 5:25
• I guessed so, but I'm sure it can be simplified. Could you at least post the scan of a drawing of what you try to achieve? – Bernard Sep 7 '15 at 8:08
• Perfect. I'll look at it later today. – Bernard Sep 7 '15 at 8:48