I have to nodes (V1) and (V2) (representing sets of graph vertices) and I want to draw, say, 10 edges(lines) between them. I don't want to hardcode random locations so I did:
\begin{pgfonlayer}{bg} % so they don't overlap the graphic representation of V1 and V2
\draw (V1)+(rand*.3,rand*.3) -- (V2)+(rand*.3,rand*.3);
\draw (V1)+(rand*.3,rand*.3) -- (V2)+(rand*.3,rand*.3);
\draw (V1)+(rand*.3,rand*.3) -- (V2)+(rand*.3,rand*.3);
% ... repeat more 7 times ... (PS:I know tikz has a repeat/foreach/... command -
\end{pgfonlayer}
copying and pasting was just for being lazy)
There are two problems with this approach:
- (Main one) Lines are starting at random locations within V1 but they always end on the center if V2 --- as if rnd was returning 0 in those cases.
- (Not that important) When using \pause, the value are randomized again on the next slide which is not desired in my case. I realize I should store somehow those random values so that does not happen. But personally, if doing this makes the solution much harder I prefer not to solve it.
- (OK, bonus one) Is there a way to change the style of those edges (ie, turn them to dashed) on the next slide (ie, after a pause). (Apparently,
\draw[\alt{2}{...}{...}]
doesn't work..
V2
, after all it is the point you specified after--
, the following+(…)
specifies a new Move-To operation (as does the one after(V1)
). Use([shift={(rnd*.3,rnd*.3)}] V2)
orcalc
instead. — For a discussion about TikZ in combination withbeamer
overlays, see How to make beamer overlays with Tikz node