I am trying to nest tikz graph environments into the nodes of a tikz graph environment:
\begin{tikzpicture}
\graph [layered layout]{
ABABAB -> {
AB -> {A, B},
BA -> {A, B}
};
};
\end{tikzpicture}
I got this so far and I need to make each node its own graph with a similar layout.
I also want to be able to connect nodes from the inner graphs with nodes of the outer graph.
I could create all nodes individually and connect them, with nested nodes like this:
\node [draw] at (0,0) (container1) {
\begin{tikzpicture}
\node at (0,0) (container1label) {Node 1};
\node [draw,below=0.4 of container1label] (child1) {Node 1's Child};
\end{tikzpicture}
};
But I would like to have the layout automatically taken care of.
Ideally I would create the outer graph with invisible edges, so the layout is appropriate, and then connect the inner nodes of the graphs with each other manually.
Is there some way to nest a tikzpicture
in a node created in a \graph
environment?
Edit:
To make it more clear, this is what I am trying to model. A formal grammar composed of rules. I need an outer node for each left side of a rule and inside these outer nodes I would like to be able to create new nodes for each symbol and connect them with their corresponding outer nodes.
For example, I would like the outer node of abcdef
to contain nodes for ab
, cde
, f
, a
, bc
and def
(preferrably easily laid out as shown in the picture, in two lines) and then I need an edge from each of these inner nodes to their corresponding outer node, which in turn contains its rule's symbols.
A simpler solution might be to only connect the outer nodes with each other if they have rules pointing to each other, but I wouldn't even know how to define a math text content for each node in the graph
environment. Preferrably I would like to connect each inner symbol node with each outer rule node, though.
So similar to this:
tikzpicture
s can be nested, and if so, each node could be one, with a "big" one wrapped around all the little ones.tikzpicture
s. The results of trying to do so are (almost) always unpredictable and (almost) always not what you want. The settings of the outside picture will change the output of the inner one, while the stuff inside the inner one won't be accessible in the outer one. You can use things such astikzmark
to create subnodes you can refer to outside the currenttikzpicture
(or outside one) and you can useremember picture
, for example, but nesting them is a can of worms.graphdrawing
supports sublayouts and if that doesn't do what you need and as long as you don't need a transformation you might be able to use a PGF/TikZ matrix which is very close to putting a TikZ picture inside a node but actually supported. Whethergraphdrawing
can deal with it is another story, though.