1

I am building a graph with nodes and edges in Tikz. Is there any commend which returns array of connected nodes to a particular node? for example, I have 3 nodes A,B,C and only A and C are connected and now, I need a function which returns A when it is invoked on C (following code). Is it possible to do that? Thanks in advance!

\node (A){};
\node (B){};
\node (C){};
\path (A) edge (C);

PS: I would like some function which returns list of all connected nodes. Like returnConnectedNodes(\node (C)) and this gives me A or more connected nodes in array.

  • 2
    Perhaps if you could provide a complete minimal example (rather than a mere code fragment) and some sense of what you are trying to do, somebody might be able to suggest an alternative approach. Because, to the best of my knowledge, there is nothing like this. TikZ does not keep track of things in this way. It is just a picture. Presumably the graph drawing algorithms available using Lua must do something like this, but I don't know whether it exposes this kind of function to the user. In any case, this may not be a graph. – cfr Apr 14 '16 at 23:02
  • 1
    You could always record the names in a tikz array or delimited string (xstring package), but it wouldn't be automatic. – John Kormylo Apr 14 '16 at 23:49
  • When I say 'this may not be a graph', I should be clear: I mean that it isn't clear whether it is technically a graph in the relevant sense. I realise it is described as a 'graph' in some sense. – cfr Apr 15 '16 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.