Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph drawing doesn't work with name prefix #1087

Closed
muzimuzhi opened this issue Dec 7, 2021 · 1 comment · Fixed by #1119
Closed

Graph drawing doesn't work with name prefix #1087

muzimuzhi opened this issue Dec 7, 2021 · 1 comment · Fixed by #1119
Labels

Comments

@muzimuzhi
Copy link
Member

Brief outline of the bug

When name prefix (or name suffix) is set, graph drawing throws Lua error

...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:510: attempting to create edge between nodes c and a that are not in the graph
stack traceback:
	[C]: in function 'assert'
	...graphdrawing/lua/pgf/gd/interface/InterfaceToDisplay.lua:510: in function 'pgf.gd.interface.InterfaceToDisplay.createEdge'
	[\directlua]:1: in main chunk.
\pgfgdedge ...uaescapestring {\the \toks 1}', }) }
                                                  \endpgfinterruptpath }}\en...

Minimal working example (MWE)

% !TeX program = lualatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{layered}

\begin{document}
% without graphdrawing
\tikz                \graph { {a,b} -> c }; % works
\tikz[name prefix=x] \graph { {a,b} -> c }; % works

% with graphdrawing
\tikz                \graph[layered layout] { {a,b} -> c }; % works
\tikz[name prefix=x] \graph[layered layout] { {a,b} -> c }; % lua error
\tikz[name prefix=x] \graph[layered layout, /tikz/name prefix=]
                       { {a,b} -> c };                      % works again
\end{document}

I don't speak Lua, but by adding print() to function InterfaceToDisplay.createEdge(), I find when the error is thrown,
see lines 482--484 below, head == 'c' and tail == 'a'. However the keys stored in table scope.node_names is xa, xb, xc. Hence both h and t are nil and the assert() fails.

function InterfaceToDisplay.createEdge(tail, head, direction, height, binding_infos)
-- Setup
local scope = InterfaceCore.topScope()
local binding = InterfaceCore.binding
-- Does vertex already exist?
local h = scope.node_names[head]
local t = scope.node_names[tail]
assert (h and t, "attempting to create edge between nodes that are not in the graph")
-- Create Arc object
local arc = scope.syntactic_digraph:connect(t, h)
-- Create Edge object
local edge = Edge.new {
head = h,
tail = t,
direction = direction,
options = get_current_options_table(height)
}

@hmenke
Copy link
Member

hmenke commented Dec 9, 2021

Probably \graph doesn't wrap node names in \tikz@pp@name{<name>}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants