Get rid of `for` loops to construct $L$ I have a kind of implicit characterization of the adjacency matrix $L$ of a directed line graph of an undirected graph on $n$ vertices (each edge in the undirected graph is represented by a pair of directed edges, back and forth). Given $A$ the adjacency matrix of the undirected graph I found that the matrix element at $(ab_n,bc_n)$ ($xy_n$ is a $n$-ary two digit number) of $L$ looks like the following:
$$
L_{ab_n,bc_n}=\langle a|A|b \rangle \! \langle b|A|c \rangle,
$$
where $a,b,c\in\{1,\dots,n\}$. I can use three forloops (for $a,b,c$ each running from $1$ to $n$) to construct $L$, but is it possible to do that directly, by using e.g. superoperator formalism?
EDIT If it helps: An answer for bipartite cubic planar graphs is fair enough...
We can use a permutation matrix $S$ to get
 $$
L_{ab_n,bc_n}=S\circ L_{ab_n,cb_n},
$$
where the latter has the same structure as the following kronecker product:
$$
\pmatrix{1&\cdots& 1\\ \vdots&&\vdots\\1&\cdots& 1}\otimes \text{diag}(1,\dots,1)
$$
 A: This is not not really an answer to the stated question. I posted this to hopefully clarify the situation so that someone else will find a proper solution. However, I did find something interesting that might help.
First, we have $A$, an $n\times n$ adjacency matrix for an undirected graph. Because this is an undirected graph, $A$ is symmetric, i.e. $A_{i, j} = A_{j, i}$ (since an edge from $i$ to $j$ in an undirected graph is the same as the edge from $j$ to $i$), or $A^T = A$.
OP wishes to generate $L$, an $n^2 \times n^2$ adjacency matrix for matrix $A$. Row or column $i$ in $L$ shall correspond to row $r$, column $c$ in $A$, with $i = r a + c$. This can be defined as
$$L_{n a + b,\; n b + c} = A_{a,b} A_{b,c}$$
The original question, if I've understood correctly, is whether or not there is a simpler way to calculate $L$ than explicitly element-wise as above.
At least $(n-1)/n$ of it will be filled with zeroes, as can be expected, since at most $n^3$ of the $n^4$ elements are assigned to using the above element-wise assignment. 
It turns out that $L$ has a very explicit pattern. For example, if $n = 3$, then
$$L = \left [ \begin{matrix}
A_{11} A_{11} & A_{11} A_{12} & A_{11} A_{13} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & A_{12} A_{21} & A_{12} A_{22} & A_{12} A_{23} & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & A_{13} A_{31} & A_{13} A_{32} & A_{13} A_{33} \\
A_{21} A_{11} & A_{21} A_{12} & A_{21} A_{13} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & A_{22} A_{21} & A_{22} A_{22} & A_{22} A_{23} & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & A_{23} A_{31} & A_{23} A_{32} & A_{23} A_{33} \\
A_{31} A_{11} & A_{31} A_{12} & A_{31} A_{13} & 0 & 0 & 0 & 0 & 0 & 0 \\
 0 & 0 & 0 & A_{32} A_{21} & A_{32} A_{22} & A_{32} A_{23} & 0 & 0 & 0 \\
 0 & 0 & 0 & 0 & 0 & 0 & A_{33} A_{31} & A_{33} A_{32} & A_{33} A_{33}
\end{matrix} \right ]$$
The possibly nonzero entries in $L$ form $n$ $n\times n$ matrices. Let's call these $P_1$ through $P_n$, so that $P_1$ defines the $n$ leftmost columns in $L$, $P_2$ the next $n$ columns, and so on, with $P_n$ defining the rightmost $n$ columns in $L$. Note that each $P_i$ defines every $n$'th row, starting at row $i$. (I do not know of a simple way to mathematically represent the row distribution from $P_i$ to $L$, though.)
It is now rather obvious that
$$P_i = A_{col=i} A_{row=i}$$
where $A_{col=i}$ refers to the column $i$ of $A$ as a column vector, and $A_{row=i}$ refers to the row $i$ of $A$ as a row vector.
Furthermore, since $A$ is symmetric, $P_i$ are too.
(Programmatically, this means that since entries in $A$ are binary or boolean (connected / not connected), each zero entry clears an entire row and entire column in $P_i$, and since $A_{col=i} = A_{row=i}^T$, a single consecutive memory chunk needs to be examined to construct each $P_i$. Personally, I wouldn't even compute $L$ explicitly, but use a function that computes any requested entries as needed from $A$, using short-circuit logic.)
As I mentioned above, I don't know of a neat way to mathematically express the construction of the $P_i$ and their distribution into $L$, in case that is what the OP really needs, but perhaps someone else can construct a suggestion?
