Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
How can I reuse a set of nodes in Tikz?
I have a graph in TikZ which I would like to use multiple times, with variations. As a simple example, say I have the following set of nodes
\begin{tikzpicture}
\node (a) at (0, 0) [circle,draw] {a};
\node (b) at (1, 0) [circle,draw] {b};
\node (c) at (1, 1) [circle,draw] {c};
\end{tikzpicture}
In the first graph, I'd like to simply draw edges from a to b, b to c, and c to a. In the second graph, I'd like to do the same thing, but with some bold edges, and maybe an additional node. And so on.
Instead of copying this multiple times, is there an easy way to reuse a set of nodes in each graph?
In addition, it would be good if it worked with the graph drawing algorithms, since simply copy-pastes results in slightly different computed positions even with the same random seed, so I'd like to generate the node positions once and reuse them.
1 comment thread