Ideally, I wish would like a command \vertex such that it behaves as
\vertex (a); ---> \node[empty vertex] (a) {};
\vertex[foo] (a); ---> \node[empty vertex, foo] (a) {};
\vertex[foo] (a) at (0, 0); ---> \node[empty vertex, foo] (a) at (0, 0) {};
\vertex (a) {bar}; ---> \node[filled vertex] (a) {bar};
and similarly for various other combinations; but I have no idea how to even write such a function.
Does anyone have any idea if or how this could be achieved?
As a fallback, is it possible for a node style to depend on the node content? This way, one would always have to write the final {...}, but the end result would vary depending on whether these braces are filled or not.
My first thought for this fallback was to try implementing a style like
\tikzset{
vertex/.append code={
\ifx\tikz@node@content\relax
\pgfkeysalso{/tikz/shape=coordinate}
\else
\pgfkeysalso{/tikz/shape=circle}
\pgfkeysalso{/tikz/draw}
\fi
},
}
However, this does not seem to work because the style will be parsed before \tikz@node@content is populated[1], so the true branch is always executed.
Ultimately,
[1]: This is based on looking at tikz.code.tex, specifically, line 3668 where \tikz@node@content is set.


coordinatewhen it's empty and likenodeif it contains text. Some not very elaborated suggestions. First:matrixlibrary contains something aboutnodes on empty cells. Second: Why not draw acoordinateand add an optional node over it when text is present? May be withappend after commandorinsert pathorpgfextra. (I'm not sure if these commands serve for this) – Ignasi Apr 30 '15 at 09:25nodes in empty cells. By the way\tikz@node@contentmay not contains the actual content since TikZ accepts code like\tikz\node{\verb|%|};– Symbol 1 Apr 30 '15 at 15:05matrixand the way it handlesnodes in empty cellsand it seems like it parses the matrix node's content and inserts the appropriate TikZ commands as it goes, effectively wrapping the matrix contents. It doesn't seem to ever read the contents of the matrix sub-nodes. I will have a look at checking whether I can use a style to create a 1x1 matrix.Also, why would
– JP-Ellis May 01 '15 at 05:35\tikz\node{\verb|%|};cause an issue?