diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-08 21:09:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-08 21:09:31 +0000 |
commit | 3de6683607c3042def19b77ca8a338814d0a1575 (patch) | |
tree | 106d17a816c9eb899d2943cbadb33aa9b627f4ca /Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control | |
parent | 3e178d666f929257b38c4d6857bccf4076145c29 (diff) |
pgf revert again to r49607, after mistaken update
git-svn-id: svn://tug.org/texlive/trunk@51047 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control')
14 files changed, 1347 insertions, 1344 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Anchoring.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Anchoring.lua index 03a05ee627d..ccbb097583c 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Anchoring.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Anchoring.lua @@ -23,29 +23,29 @@ -- \emph{absolutely} once all relative positions have been computed. In -- case that the graph consists of several unconnected components, the -- situation is even more complicated. --- +-- -- The order in which the algorithm layer determines the node at which -- the graph should be anchored: --- % +-- -- \begin{enumerate} --- \item If the |anchor node=|\meta{node name} option given to the graph --- as a whole, the graph is anchored at \meta{node name}, provided --- there is a node of this name in the graph. (If there is no node of --- this name or if it is misspelled, the effect is the same as if this --- option had not been given at all.) --- \item Otherwise, if there is a node where the |anchor here| option is --- specified, the first node with this option set is used. --- \item Otherwise, if there is a node where the |desired at| option is --- set (perhaps implicitly through keys like |x|), the first such node --- is used. --- \item Finally, in all other cases, the first node is used. +-- \item If the |anchor node=|\meta{node name} option given to the graph +-- as a whole, the graph is anchored at \meta{node name}, provided +-- there is a node of this name in the graph. (If there is no node of +-- this name or if it is misspelled, the effect is the same as if this +-- option had not been given at all.) +-- \item Otherwise, if there is a node where the |anchor here| option is +-- specified, the first node with this option set is used. +-- \item Otherwise, if there is a node where the |desired at| option is +-- set (perhaps implicitly through keys like |x|), the first such node +-- is used. +-- \item Finally, in all other cases, the first node is used. -- \end{enumerate} -- -- In the above description, the ``first'' node refers to the node first -- encountered in the specification of the graph. -- -- Once the node has been determined, the graph is shifted so that --- this node lies at the position specified by |anchor at|. +-- this node lies at the poistion specified by |anchor at|. -- -- @end @@ -70,7 +70,7 @@ declare { type = "coordinate", documentation_in = "pgf.gd.control.doc" } - + --- declare { key = "anchor node", diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua index 5e5b0635bf4..dec07caaccd 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentAlign.lua @@ -47,22 +47,22 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- @end - + --- - + declare { key = "align here", type = "boolean", - summary = [[" - When this option is given to a node, this alignment line will go - through the origin of this node. If this option is passed to more - than one node of a component, the node encountered first in the - component is used. + summary = [[" + When this option is given to a node, this alignment line will go + through the origin of this node. If this option is passed to more + than one node of a component, the node encountered first in the + component is used. "]], - examples = [[" - \tikz \graph [binary tree layout, nodes={draw}] - { a, b -- c[align here], d -- e[second, align here] -- f }; + examples = [[" + \tikz \graph [binary tree layout, nodes={draw}] + { a, b -- c[align here], d -- e[second, align here] -- f }; "]] } @@ -72,94 +72,81 @@ declare { key = "component align", type = "string", initial = "first node", - + summary = [[" Specifies a ``strategy'' for the alignment of components. "]], - documentation = [[" - The following values are permissible: - % - \begin{itemize} - \item \declare{|first node|} - - In each component, the alignment line goes through the center of - the first node of the component encountered during specification - of the component. - % + documentation = [[" + The following values are permissible: + \begin{itemize} + \item \declare{|first node|} + In each component, the alignment line goes through the center of + the first node of the component encountered during specification + of the component. \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component align=first node] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % - \item \declare{|center|} - - The nodes of the component are projected onto the shift line. The - alignment line is now chosen so that it is exactly in the middle - between the maximum and minimum value that the projected nodes - have on the shift line. - % + \item \declare{|center|} + + The nodes of the component are projected onto the shift line. The + alignment line is now chosen so that it is exactly in the middle + between the maximum and minimum value that the projected nodes + have on the shift line. \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component align=center] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=center] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % - \item \declare{|counterclockwise|} - - As for |center|, we project the nodes of the component onto the - shift line. The alignment line is now chosen so that it goes - through the center of the node whose center has the highest - projected value. - % + \item \declare{|counterclockwise|} + + As for |center|, we project the nodes of the component onto the + shift line. The alignment line is now chosen so that it goes + through the center of the node whose center has the highest + projected value. \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component align=counterclockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=counterclockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - The name |counterclockwise| is intended to indicate that the align - line goes through the node that comes last if we go from the - alignment direction in a counter-clockwise direction. - \item \declare{|clockwise|} - - Works like |counterclockwise|, only in the other direction: - % + The name |counterclockwise| is intended to indicate that the align + line goes through the node that comes last if we go from the + alignment direction in a counter-clockwise direction. + \item \declare{|clockwise|} + + Works like |counterclockwise|, only in the other direction: \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component align=clockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % \begin{codeexample}[] \tikz \graph [binary tree layout, nodes={draw}, component direction=90, component align=clockwise] { a, b -- c, d -- e[second] -- f }; \end{codeexample} - % - \item \declare{|counterclockwise bounding box|} - - This method is quite similar to |counterclockwise|, only the - alignment line does not go through the center of the node with a - maximum projected value on the shift line, but through the maximum - value of the projected bounding boxes. For a left-to-right - packing, this means that the components are aligned so that the - bounding boxes of the components are aligned at the top. - % + \item \declare{|counterclockwise bounding box|} + + This method is quite similar to |counterclockwise|, only the + alignment line does not go through the center of the node with a + maximum projected value on the shift line, but through the maximum + value of the projected bounding boxes. For a left-to-right + packing, this means that the components are aligned so that the + bounding boxes of the components are aligned at the top. \begin{codeexample}[] \tikz \graph [tree layout, nodes={draw, align=center}, component sep=0pt, @@ -170,11 +157,10 @@ declare { component align=counterclockwise bounding box] { a, "high\\node" -- b}; \end{codeexample} - % - \item \declare{|clockwise bounding box|} - - Works like |counterclockwise bounding box|. - \end{itemize} + \item \declare{|clockwise bounding box|} + + Works like |counterclockwise bounding box|. + \end{itemize} "]] } @@ -187,16 +173,16 @@ declare { { key = "component align", value = "counterclockwise"}, }, - summary = [[" - Shorthand for |component direction=right| and - |component align=counterclockwise|. This means that, as the name - suggest, the components will be placed left-to-right and they are - aligned such that their top nodes are in a line. + summary = [[" + Shorthand for |component direction=right| and + |component align=counterclockwise|. This means that, as the name + suggest, the components will be placed left-to-right and they are + aligned such that their top nodes are in a line. "]], - examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go right top aligned] - { a, "high\\node" -- b}; + examples = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go right top aligned] + { a, "high\\node" -- b}; "]] } @@ -208,17 +194,17 @@ declare { { key = "component direction", value=0}, { key = "component align", value = "counterclockwise bounding box"}, }, - - summary = [[" - Like |components go right top aligned|, but with - |component align| set to |counterclockwise| |bounding box|. - This means that the components will be aligned with their bounding - boxed being top-aligned. + + summary = [[" + Like |components go right top aligned|, but with + |component align| set to |counterclockwise| |bounding box|. This means that the + components will be aligned with their bounding boxed being + top-aligned. "]], examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go right absolute top aligned] - { a, "high\\node" -- b}; + \tikz \graph [tree layout, nodes={draw, align=center}, + components go right absolute top aligned] + { a, "high\\node" -- b}; "]] } @@ -230,7 +216,7 @@ declare { { key = "component direction", value=0}, { key = "component align", value = "clockwise"}, }, - + summary = "See the other |components go ...| keys." } @@ -243,7 +229,7 @@ declare { { key = "component direction", value=0}, { key = "component align", value = "clockwise bounding box"}, }, - + summary = "See the other |components go ...| keys." } @@ -256,7 +242,7 @@ declare { { key = "component direction", value=0}, { key = "component align", value = "center"}, }, - + summary = "See the other |components go ...| keys." } @@ -269,11 +255,11 @@ declare { { key = "component direction", value=0}, { key = "component align", value = "first node"}, }, - - summary = [[" - Shorthand for |component direction=right| and - |component align=first node|. - "]] + + summary = [[" + Shorthand for |component direction=right| and + |component align=first node|. + "]] } @@ -285,13 +271,13 @@ declare { { key = "component direction", value=180}, { key = "component align", value = "clockwise"}, }, - + summary = "See the other |components go ...| keys.", - examples = [[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go left top aligned] - { a, "high\\node" -- b}; + examples = [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go left top aligned] + { a, "high\\node" -- b}; "]] } @@ -304,7 +290,7 @@ declare { { key = "component direction", value=180}, { key = "component align", value = "clockwise bounding box"}, }, - + summary = "See the other |components go ...| keys." } @@ -318,7 +304,7 @@ declare { { key = "component direction", value=180}, { key = "component align", value = "counterclockwise"}, }, - + summary = "See the other |components go ...| keys." } @@ -332,7 +318,7 @@ declare { { key = "component direction", value=180}, { key = "component align", value = "counterclockwise bounding box"}, }, - + summary = "See the other |components go ...| keys." } @@ -374,15 +360,17 @@ declare { }, summary = "See the other |components go ...| keys.", - examples = {[[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go down left aligned] - { a, hello -- {world,s} }; - "]],[[" - \tikz \graph [tree layout, nodes={draw, align=center}, - components go up absolute left aligned] - { a, hello -- {world,s}}; - "]] + examples = { + [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go down left aligned] + { a, hello -- {world,s} }; + "]], + [[" + \tikz \graph [tree layout, nodes={draw, align=center}, + components go up absolute left aligned] + { a, hello -- {world,s}}; + "]] } } diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua index f941ff226ec..a84800d94cf 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDirection.lua @@ -25,32 +25,35 @@ declare { type = "direction", initial = "0", - summary = [[" - The \meta{angle} is used to determine the relative position of each - component relative to the previous one. The direction need not be a - multiple of |90|. As usual, you can use texts like |up| or - |right| instead of a number. + summary = [[" + The \meta{angle} is used to determine the relative position of each + component relative to the previous one. The direction need not be a + multiple of |90|. As usual, you can use texts like |up| or + |right| instead of a number. "]], - documentation = [[" - As the examples show, the direction only has an influence on the - relative positions of the components, not on the direction of growth - inside the components. In particular, the components are not rotated - by this option in any way. You can use the |grow| option or |orient| - options to orient individual components. + documentation = [[" + As the examples show, the direction only has an influence on the + relative positions of the components, not on the direction of growth + inside the components. In particular, the components are not rotated + by this option in any way. You can use the |grow| option or |orient| + options to orient individual components. "]], - examples = {[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=left] - { a, b, c -- d -- e, f -- g }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=10] - { a, b, c -- d -- e, f -- g }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component direction=up] - { a, b, c [grow=right] -- d -- e, f[grow=45] -- g }; - "]] + examples = { + [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=left] + { a, b, c -- d -- e, f -- g }; + "]], + [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=10] + { a, b, c -- d -- e, f -- g }; + "]], + [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component direction=up] + { a, b, c [grow=right] -- d -- e, f[grow=45] -- g }; + "]] } } diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua index 7ba4d000a7a..5bf473e9c6a 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentDistance.lua @@ -23,7 +23,7 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- @end - + --- declare { @@ -31,74 +31,70 @@ declare { type = "string", initial = "skyline", - documentation = [[" - Given two components, their distance is computed as follows in - dependence of \meta{method}: - % - \begin{itemize} - \item \declare{|rectangular|} - - Imagine a bounding box to be drawn around both components. They - are then shifted such that the padding (separating distance) - between the two boxes is the current value of |component sep|. - % - \begin{codeexample}[] - \tikz \graph [tree layout, nodes={draw}, component sep=0pt, - component packing=rectangular] - { a -- long text, longer text -- b}; - \end{codeexample} - % - \item \declare{|skyline|} - - The ``skyline method'' is used to compute the distance. It works - as follows: For simplicity, assume that the component direction is - right (other case work similarly, only everything is - rotated). Imaging the second component to be placed far right - beyond the first component. Now start moving the second component - back to the left until one of the nodes of the second component - touches a node of the first component, and stop. Again, the - padding |component sep| can be used to avoid the nodes actually - touching each other. - % - \begin{codeexample}[] - \tikz \graph [tree layout, nodes={draw}, component sep=0pt, - level distance=1.5cm, - component packing=skyline] - { a -- long text, longer text -- b}; - \end{codeexample} - - In order to avoid nodes of the second component ``passing through - a hole in the first component'', the actual algorithm is a bit - more complicated: For both components, a ``skyline'' is - computed. For the first component, consider an arbitrary - horizontal line. If there are one or more nodes on this line, the - rightmost point on any of the bounding boxes of these nodes will - be the point on the skyline of the first component for this - line. Similarly, for the second component, for each horizontal - level the skyline is given by the leftmost point on any of the - bounding boxes intersecting the line. - - Now, the interesting case are horizontal lines that do not - intersect any of the nodes of the first and/or second - component. Such lines represent ``holes'' in the skyline. For - them, the following rule is used: Move the horizontal line upward - and downward as little as possible until a height is reached where - there is a skyline defined. Then the skyline position on the - original horizontal line is the skyline position at the reached - line, minus (or, for the second component, plus) the distance by - which the line was moved. This means that the holes are ``filled - up by slanted roofs''. - % - \begin{codeexample}[] - \begin{tikzpicture} - \graph [tree layout, nodes={draw}, component sep=0pt, - component packing=skyline] - { a -- long text, longer text -- b}; - \draw[red] (long text.north east) -- ++(north west:1cm); - \end{tikzpicture} - \end{codeexample} - - \end{itemize} + documentation = [[" + Given two components, their distance is computed as follows in + depencende of \meta{method}: + \begin{itemize} + \item \declare{|rectangular|} + + Imagine a bounding box to be drawn around both components. They + are then shifted such that the padding (separating distance) + between the two boxes is the current value of |component sep|. + \begin{codeexample}[] + \tikz \graph [tree layout, nodes={draw}, component sep=0pt, + component packing=rectangular] + { a -- long text, longer text -- b}; + \end{codeexample} + \item \declare{|skyline|} + + The ``skyline method'' is used to compute the distance. It works + as follows: For simplicity, assume that the component direction is + right (other case work similary, only everything is + rotated). Imaging the second component to be placed far right + beyond the first component. Now start moving the second component + back to the left until one of the nodes of the second component + touches a node of the first component, and stop. Again, the + padding |component sep| can be used to avoid the nodes actually + touching each other. + + \begin{codeexample}[] + \tikz \graph [tree layout, nodes={draw}, component sep=0pt, + level distance=1.5cm, + component packing=skyline] + { a -- long text, longer text -- b}; + \end{codeexample} + + In order to avoid nodes of the second component ``passing through + a hole in the first component,'' the actual algorithm is a bit + more complicated: For both components, a ``skyline'' is + computed. For the first component, consider an arbitrary + horizontal line. If there are one or more nodes on this line, the + rightmost point on any of the bounding boxes of these nodes will + be the point on the skyline of the first component for this + line. Similarly, for the second component, for each horizontal + level the skyline is given by the leftmost point on any of the + bounding boxes intersecting the line. + + Now, the interesting case are horizontal lines that do not + intersect any of the nodes of the first and/or second + component. Such lines represent ``holes'' in the skyline. For + them, the following rule is used: Move the horizontal line upward + and downward as little as possible until a height is reached where + there is a skyline defined. Then the skyline position on the + original horizontal line is the skyline position at the reached + line, minus (or, for the second component, plus) the distance by + which the line was moved. This means that the holes are ``filled + up by slanted roofs.'' + \begin{codeexample}[] + \begin{tikzpicture} + \graph [tree layout, nodes={draw}, component sep=0pt, + component packing=skyline] + { a -- long text, longer text -- b}; + \draw[red] (long text.north east) -- ++(north west:1cm); + \end{tikzpicture} + \end{codeexample} + + \end{itemize} "]] } diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua index 78537b614cd..0cad5d7d9b5 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/ComponentOrder.lua @@ -13,7 +13,7 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare - + --- -- @section subsubsection {Ordering the Components} @@ -33,44 +33,46 @@ declare { initial = "by first specified node", summary = [[" - Selects a ``strategy'' for ordering the components. By default, - they are ordered in the way they appear in the input. + Selects a ``strategy'' for ordering the components. By default, + they are ordered in the way they appear in the input. "]], - documentation = [[" - The following values are permissible for \meta{strategy} - % - \begin{itemize} - \item \declare{|by first specified node|} - - The components are ordered ``in the way they appear in the input - specification of the graph''. More precisely, for each component - consider the node that is first encountered in the description - of the graph. Order the components in the same way as these nodes - appear in the graph description. - \item \declare{|increasing node number|} - - The components are ordered by increasing number of nodes. For - components with the same number of nodes, the first node in each - component is considered and they are ordered according to the - sequence in which these nodes appear in the input. - - \item \declare{|decreasing node number|} - As above, but in decreasing order. - \end{itemize} + documentation = [[" + The following values are permissible for \meta{strategy} + \begin{itemize} + \item \declare{|by first specified node|} + + The components are ordered ``in the way they appear in the input + specification of the graph''. More precisely, for each component + consider the node that is first encountered in the description + of the graph. Order the components in the same way as these nodes + appear in the graph description. + + \item \declare{|increasing node number|} + + The components are ordered by increasing number of nodes. For + components with the same number of nodes, the first node in each + component is considered and they are ordered according to the + sequence in which these nodes appear in the input. + + \item \declare{|decreasing node number|} + As above, but in decreasing order. + \end{itemize} "]], - examples = {[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component order=by first specified node] - { a, b, c, f -- g, c -- d -- e }; - "]],[[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - component order=increasing node number] - { a, b, c -- d -- e, f -- g }; - "]] + examples = { + [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component order=by first specified node] + { a, b, c, f -- g, c -- d -- e }; + "]], + [[" + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + component order=increasing node number] + { a, b, c -- d -- e, f -- g }; + "]] } -} - - +} + + --- declare { @@ -79,11 +81,11 @@ declare { { key = "component order", value = "increasing node number" } }, - summary = [[" - A shorthand for |component order=increasing node number|. - "]] + summary = [[" + A shorthand for |component order=increasing node number|. + "]] } - + --- declare { @@ -91,15 +93,15 @@ declare { use = { { key = "component order", value = "decreasing node number" }, }, - summary = [[" - A shorthand for |component order=decreasing node number|. + summary = [[" + A shorthand for |component order=decreasing node number|. "]], examples = [[" - \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, - large components first] - { a, b, c -- d -- e, f -- g }; + \tikz \graph [tree layout, nodes={inner sep=1pt,draw,circle}, + large components first] + { a, b, c -- d -- e, f -- g }; "]] -} +} return Components
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua index c5019a56e23..9d9621e6da4 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Components.lua @@ -35,57 +35,57 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- The default method for placing the different components works as -- follows: --- % +-- -- \begin{enumerate} --- \item For each component, a layout is determined and the component is --- oriented as described --- Section~\ref{subsection-library-graphdrawing-standard-orientation} --- on the orientation of graphs. --- \item The components are sorted as prescribed by the --- |component order| key. --- \item The first component is now placed (conceptually) at the --- origin. (The final position of this and all other components will be --- determined later, namely in the anchoring phase, but let us imagine --- that the first component lies at the origin at this point.) --- \item The second component is now positioned relative to the first --- component. The ``direction'' in which the next component is placed --- relative to the first one is determined by the |component direction| --- key, so components can be placed from left to right or up to down or --- in any other direction (even something like $30^\circ$). However, --- both internally and in the following description, we assume that the --- components are placed from left to right; other directions are --- achieved by doing some (clever) rotating of the arrangement achieved --- in this way. +-- \item For each component, a layout is determined and the component is +-- oriented as described +-- Section~\ref{subsection-library-graphdrawing-standard-orientation} +-- on the orientation of graphs. +-- \item The components are sorted as prescribed by the +-- |component order| key. +-- \item The first component is now placed (conceptually) at the +-- origin. (The final position of this and all other components will be +-- determined later, namely in the anchoring phase, but let us imagine +-- that the first component lies at the origin at this point.) +-- \item The second component is now positioned relative to the first +-- component. The ``direction'' in which the next component is placed +-- relative to the first one is determined by the |component direction| +-- key, so components can be placed from left to right or up to down or +-- in any other direction (even something like $30^\circ$). However, +-- both internally and in the following description, we assume that the +-- components are placed from left to right; other directions are +-- achieved by doing some (clever) rotating of the arrangement achieved +-- in this way. -- --- So, we now wish to place the second component to the right of the --- first component. The component is first shifted vertically according --- to some alignment strategy. For instance, it can be shifted so that --- the topmost node of the first component and the topmost node of the --- second component have the same vertical position. Alternatively, we --- might require that certain ``alignment nodes'' in both components --- have the same vertical position. There are several other strategies, --- which can be configured using the |component align| key. +-- So, we now wish to place the second component to the right of the +-- first component. The component is first shifted vertically according +-- to some alignment strategy. For instance, it can be shifted so that +-- the topmost node of the first component and the topmost node of the +-- second component have the same vertical position. Alternatively, we +-- might require that certain ``alignment nodes'' in both components +-- have the same vertical position. There are several other strategies, +-- which can be configured using the |component align| key. -- --- One the vertical position has been fixed, the horizontal position is --- computed. Here, two different strategies are available: First, image --- rectangular bounding boxed to be drawn around both components. Then --- we shift the second component such that the right border of the --- bounding box of the first component touches the left border of the --- bounding box of the second component. Instead of having the bounding --- boxes ``touch'', we can also have a padding of |component sep| --- between them. The second strategy is more involved and also known as --- a ``skyline'' strategy, where (roughly) the components are --- ``moved together as near as possible so that nodes do not touch''. --- \item --- After the second component has been placed, the third component is --- considered and positioned relative to the second one, and so on. --- \item --- At the end, as hinted at earlier, the whole arrangement is rotate so --- that instead of ``going right'' the component go in the direction of --- |component direction|. Note, however, that this rotation applies only --- to the ``shift'' of the components; the components themselves are --- not rotated. Fortunately, this whole rotation process happens in the --- background and the result is normally exactly what you would expect. +-- One the vertical position has been fixed, the horizontal position is +-- computed. Here, two different strategies are available: First, image +-- rectangular bounding boxed to be drawn around both components. Then +-- we shift the second component such that the right border of the +-- bounding box of the first component touches the left border of the +-- bounding box of the second component. Instead of having the bounding +-- boxes ``touch,'' we can also have a padding of |component sep| +-- between them. The second strategy is more involved and also known as +-- a ``skyline'' strategy, where (roughly) the components are +-- ``moved together as near as possible so that nodes do not touch''. +-- \item +-- After the second component has been placed, the third component is +-- considered and positioned relative to the second one, and so on. +-- \item +-- At the end, as hinted at earlier, the whole arrangement is rotate so +-- that instead of ``going right'' the component go in the direction of +-- |component direction|. Note, however, that this rotation applies only +-- to the ``shift'' of the components; the components themselves are +-- not rotated. Fortunately, this whole rotation process happens in the +-- background and the result is normally exactly what you would expect. -- \end{enumerate} -- -- In the following, we go over the different keys that can be used to @@ -95,33 +95,35 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare --- - + declare { key = "componentwise", type = "boolean", - summary = [[" - For algorithms that also support drawing unconnected graphs, use - this key to enforce that the components of the graph are, - nevertheless, laid out individually. For algorithms that do not - support laying out unconnected graphs, this option has no effect; - rather it works as if this option were always set. + summary = [[" + For algorithms that also support drawing unconnected graphs, use + this key to enforce that the components of the graph are, + nevertheless, laid out individually. For algorithms that do not + support laying out unconnected graphs, this option has no effect; + rather it works as if this option were always set. "]], - examples = {[[" - \tikz \graph [simple necklace layout] - { - a -- b -- c -- d -- a, - 1 -- 2 -- 3 -- 1 - }; - "]],[[", - \tikz \graph [simple necklace layout, componentwise] - { - a -- b -- c -- d -- a, - 1 -- 2 -- 3 -- 1 - }; - "]] + examples = { + [[" + \tikz \graph [simple necklace layout] + { + a -- b -- c -- d -- a, + 1 -- 2 -- 3 -- 1 + }; + "]], + [[", + \tikz \graph [simple necklace layout, componentwise] + { + a -- b -- c -- d -- a, + 1 -- 2 -- 3 -- 1 + }; + "]] } -} - +} + diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua index 6dc5a13018d..c1b64729fab 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Distances.lua @@ -24,24 +24,24 @@ local lib = require "pgf.gd.lib" -- general keys that will be used by many algorithms. -- -- There are different kinds of objects for which you can specify --- distances and paddings: --- % +-- distances and paddings: +-- -- \begin{itemize} --- \item You specify the ``natural'' distance between nodes --- connected by an edge using |node distance|, which is also available in --- normal \tikzname\ albeit for a slightly different purpose. However, --- not every algorithm will (or can) honor the key; see the description --- of each algorithm what it will ``make of this option''. --- \item A number of graph drawing algorithms arrange nodes in layers --- (or levels); we refer --- to the nodes on the same layer as siblings (although, in a tree, --- siblings are only nodes with the same parent; nevertheless we use --- ``sibling'' loosely also for nodes that are more like ``cousins''). --- \item When a graph consists of several connected component, many graph --- drawing algorithms will layout these components individually. The --- different components will then be arranged next to each other, see --- Section~\ref{section-gd-packing} for the details, such that between --- the nodes of any two components a padding is available. +-- \item You specify the ``natural'' distance between nodes +-- connected by an edge using |node distance|, which is also available in +-- normal \tikzname\ albeit for a slightly different purpose. However, +-- not every algorithm will (or can) honour the key; see the description +-- of each algorithm what it will ``make of this option''. +-- \item A number of graph drawing algorithms arrange nodes in layers +-- (or levels); we refer +-- to the nodes on the same layer as siblings (although, in a tree, +-- siblings are only nodes with the same parent; nevertheless we use +-- ``sibling'' loosely also for nodes that are more like ``cousins''). +-- \item When a graph consists of several connected component, many graph +-- drawing algorithms will layout these components individually. The +-- different components will then be arranged next to each other, see +-- Section~\ref{section-gd-packing} for the details, such that between +-- the nodes of any two components a padding is avaiable. -- \end{itemize} -- -- @end @@ -56,23 +56,23 @@ declare { type = "length", initial = "1cm", - summary = [[" - This is minimum distance that the centers of nodes connected by an - edge should have. It will not always be possible to satisfy this - desired distance, for instance in case the nodes are too big. In - this case, the \meta{length} is just considered as a lower bound. + summary = [[" + This is minimum distance that the centers of nodes connected by an + edge should have. It will not always be possible to satisfy this + desired distance, for instance in case the nodes are too big. In + this case, the \meta{length} is just considered as a lower bound. "]], examples = [[" - \begin{tikzpicture} - \graph [simple necklace layout, node distance=1cm, node sep=0pt, - nodes={draw,circle,as=.}] - { - 1 -- 2 [minimum size=2cm] -- 3 -- - 4 -- 5 -- 6 -- 7 --[orient=up] 8 - }; - \draw [red,|-|] (1.center) -- ++(0:1cm); - \draw [red,|-|] (5.center) -- ++(180:1cm); - \end{tikzpicture} + \begin{tikzpicture} + \graph [simple necklace layout, node distance=1cm, node sep=0pt, + nodes={draw,circle,as=.}] + { + 1 -- 2 [minimum size=2cm] -- 3 -- + 4 -- 5 -- 6 -- 7 --[orient=up] 8 + }; + \draw [red,|-|] (1.center) -- ++(0:1cm); + \draw [red,|-|] (5.center) -- ++(180:1cm); + \end{tikzpicture} "]] } @@ -84,24 +84,26 @@ declare { type = "length", initial = ".333em", - summary = [[" - This is a minimum ``padding'' or ``separation'' between the border - of nodes connected by an edge. Thus, if nodes are so big that nodes - with a distance of |node distance| would overlap (or - just come with \meta{dimension} distance of one another), their - distance is enlarged so that this distance is still satisfied. - The |pre| means that the padding is added to the node ``at the - front''. This make sense only for some algorithms, like for a - simple necklace layout. + summary = [[" + This is a minimum ``padding'' or ``separation'' between the border + of nodes connected by an edge. Thus, if nodes are so big that nodes + with a distance of |node distance| would overlap (or + just come with \meta{dimension} distance of one another), their + distance is enlarged so that this distance is still satisfied. + The |pre| means that the padding is added to the node ``at the + front.'' This make sense only for some algorithms, like for a + simple necklace layout. "]], - examples = {[[" - \tikz \graph [simple necklace layout, node distance=0cm, nodes={circle,draw}] - { 1--2--3--4--5--1 }; - "]],[[" - \tikz \graph [simple necklace layout, node distance=0cm, node sep=0mm, - nodes={circle,draw}] - { 1--2--3[node pre sep=5mm]--4--5[node pre sep=1mm]--1 }; - "]] + examples = { + [[" + \tikz \graph [simple necklace layout, node distance=0cm, nodes={circle,draw}] + { 1--2--3--4--5--1 }; + "]], + [[" + \tikz \graph [simple necklace layout, node distance=0cm, node sep=0mm, + nodes={circle,draw}] + { 1--2--3[node pre sep=5mm]--4--5[node pre sep=1mm]--1 }; + "]] } } @@ -112,13 +114,13 @@ declare { type = "length", initial = ".333em", - summary = [[" - Works like |node pre sep|. - "]] + summary = [[" + Works like |node pre sep|. + "]] } + - - + --- -- @param length A length. @@ -129,9 +131,9 @@ declare { { key = "node pre sep", value = function(v) return v/2 end }, { key = "node post sep", value = function(v) return v/2 end }, }, - summary = [[" - A shorthand for setting both |node pre sep| and |node post sep| to - $\meta{length}/2$. + summary = [[" + A shorthand for setting both |node pre sep| and |node post sep| to + $\meta{length}/2$. "]] } @@ -143,26 +145,26 @@ declare { type = "length", initial = "1cm", - summary = [[" - This is minimum distance that the centers of nodes on one - level should have from the centers of nodes on the next level. It - will not always be possible to satisfy this desired distance, for - instance in case the nodes are too big. In this case, the - \meta{length} is just considered as a lower bound. + summary = [[" + This is minimum distance that the centers of nodes on one + level should have from the centers of nodes on the next level. It + will not always be possible to satisfy this desired distance, for + instance in case the nodes are too big. In this case, the + \meta{length} is just considered as a lower bound. "]], examples = [[" - \begin{tikzpicture}[inner sep=2pt] - \draw [help lines] (0,0) grid (3.5,2); - \graph [layered layout, level distance=1cm, level sep=0] - { 1 [x=1,y=2] -- 2 -- 3 -- 1 }; - \graph [layered layout, level distance=5mm, level sep=0] - { 1 [x=3,y=2] -- 2 -- 3 -- 1, 3 -- {4,5} -- 6 -- 3 }; - \end{tikzpicture} + \begin{tikzpicture}[inner sep=2pt] + \draw [help lines] (0,0) grid (3.5,2); + \graph [layered layout, level distance=1cm, level sep=0] + { 1 [x=1,y=2] -- 2 -- 3 -- 1 }; + \graph [layered layout, level distance=5mm, level sep=0] + { 1 [x=3,y=2] -- 2 -- 3 -- 1, 3 -- {4,5} -- 6 -- 3 }; + \end{tikzpicture} "]] } - + --- -declare { +declare { key = "layer distance", type = "length", use = { @@ -177,25 +179,25 @@ declare { type = "length", initial = ".333em", - summary = [[" - This is a minimum ``padding'' or ``separation'' between the border - of the nodes on a level to any nodes on the previous level. Thus, if - nodes are so big that nodes on consecutive levels would overlap (or - just come with \meta{length} distance of one another), their - distance is enlarged so that this distance is still satisfied. - If a node on the previous level also has a |level post sep|, this - post padding and the \meta{dimension} add up. Thus, these keys - behave like the ``padding'' keys rather - than the ``margin'' key of cascading style sheets. + summary = [[" + This is a minimum ``padding'' or ``separation'' between the border + of the nodes on a level to any nodes on the previous level. Thus, if + nodes are so big that nodes on consecutive levels would overlap (or + just come with \meta{lrngth} distance of one another), their + distance is enlarged so that this distance is still satisfied. + If a node on the previous level also has a |level post sep|, this + post padding and the \meta{dimension} add up. Thus, these keys + behave like the ``padding'' keys rather + than the ``margin'' key of cascading style sheets. "]], examples = [[" - \begin{tikzpicture}[inner sep=2pt, level sep=0pt, sibling distance=0pt] - \draw [help lines] (0,0) grid (3.5,2); - \graph [layered layout, level distance=0cm, nodes=draw] - { 1 [x=1,y=2] -- {2,3[level pre sep=1mm],4[level pre sep=5mm]} -- 5 }; - \graph [layered layout, level distance=0cm, nodes=draw] - { 1 [x=3,y=2] -- {2,3,4} -- 5[level pre sep=5mm] }; - \end{tikzpicture} + \begin{tikzpicture}[inner sep=2pt, level sep=0pt, sibling distance=0pt] + \draw [help lines] (0,0) grid (3.5,2); + \graph [layered layout, level distance=0cm, nodes=draw] + { 1 [x=1,y=2] -- {2,3[level pre sep=1mm],4[level pre sep=5mm]} -- 5 }; + \graph [layered layout, level distance=0cm, nodes=draw] + { 1 [x=3,y=2] -- {2,3,4} -- 5[level pre sep=5mm] }; + \end{tikzpicture} "]] } @@ -206,13 +208,13 @@ declare { type = "length", initial = ".333em", - summary = [[" - Works like |level pre sep|. - "]] + summary = [[" + Works like |level pre sep|. + "]] } - + --- -declare { +declare { key = "layer pre sep", type = "length", use = { @@ -222,7 +224,7 @@ declare { } --- -declare { +declare { key = "layer post sep", type = "length", use = { @@ -245,17 +247,17 @@ declare { { key = "level post sep", value = function (v) return v/2 end }, }, - summary = [[" - A shorthand for setting both |level pre sep| and |level post sep| to - $\meta{length}/2$. Note that if you set |level distance=0| and - |level sep=1em|, you get a layout where any two consecutive layers - are ``spaced apart'' by |1em|. + summary = [[" + A shorthand for setting both |level pre sep| and |level post sep| to + $\meta{length}/2$. Note that if you set |level distance=0| and + |level sep=1em|, you get a layout where any two consecutive layers + are ``spaced apart'' by |1em|. "]] } --- -declare { +declare { key = "layer sep", type = "number", use = { @@ -271,25 +273,28 @@ declare { type = "length", initial = "1cm", - summary = [[" - This is minimum distance that the centers of node should have to the - center of the next node on the same level. As for levels, this is - just a lower bound. - For some layouts, like a simple necklace layout, the \meta{length} is - measured as the distance on the circle. + summary = [[" + This is minimum distance that the centers of node should have to the + center of the next node on the same level. As for levels, this is + just a lower bound. + For some layouts, like a simple necklace layout, the \meta{length} is + measured as the distance on the circle. "]], - examples = {[[" - \tikz \graph [tree layout, sibling distance=1cm, nodes={circle,draw}] - { 1--{2,3,4,5} }; - "]],[[" - \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, - nodes={circle,draw}] - { 1--{2,3,4,5} }; - "]],[[" - \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, - nodes={circle,draw}] - { 1--{2,3[sibling distance=1cm],4,5} }; - "]] + examples = { + [[" + \tikz \graph [tree layout, sibling distance=1cm, nodes={circle,draw}] + { 1--{2,3,4,5} }; + "]], + [[" + \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, + nodes={circle,draw}] + { 1--{2,3,4,5} }; + "]], + [[" + \tikz \graph [tree layout, sibling distance=0cm, sibling sep=0pt, + nodes={circle,draw}] + { 1--{2,3[sibling distance=1cm],4,5} }; + "]] } } @@ -301,13 +306,13 @@ declare { type = "length", initial = ".333em", - summary = [[" - Works like |level pre sep|, only for siblings. + summary = [[" + Works like |level pre sep|, only for siblings. "]], examples = [[" - \tikz \graph [tree layout, sibling distance=0cm, nodes={circle,draw}, - sibling sep=0pt] - { 1--{2,3[sibling pre sep=1cm],4,5} }; + \tikz \graph [tree layout, sibling distance=0cm, nodes={circle,draw}, + sibling sep=0pt] + { 1--{2,3[sibling pre sep=1cm],4,5} }; "]] } @@ -318,11 +323,11 @@ declare { type = "length", initial = ".333em", - summary = [[" - Works like |sibling pre sep|. + summary = [[" + Works like |sibling pre sep|. "]] } - + --- @@ -336,26 +341,26 @@ declare { { key = "sibling post sep", value = function(v) return v/2 end }, }, - summary = [[" - A shorthand for setting both |sibling pre sep| and |sibling post sep| to - $\meta{length}/2$. + summary = [[" + A shorthand for setting both |sibling pre sep| and |sibling post sep| to + $\meta{length}/2$. "]] } + + - - - + --- declare { key = "part distance", type = "length", initial = "1.5cm", - summary = [[" - This is minimum distance between the centers of ``parts'' of a - graph. What a ``part'' is depends on the algorithm. + summary = [[" + This is minimum distance between the centers of ``parts'' of a + graph. What a ``part'' is depends on the algorithm. "]] } @@ -377,7 +382,7 @@ declare { initial = "1em", summary = "A post-padding for pars." } - + --- @@ -391,9 +396,9 @@ declare { { key = "part post sep", value = function(v) return v/2 end }, }, - summary = [[" - A shorthand for setting both |part pre sep| and |part post sep| to - $\meta{length}/2$. + summary = [[" + A shorthand for setting both |part pre sep| and |part post sep| to + $\meta{length}/2$. "]] } @@ -407,31 +412,33 @@ declare { type = "length", initial = "1.5em", - summary = [[" - This is padding between the bounding boxes that nodes of different - connected components will have when they are placed next to each - other. + summary = [[" + This is pading between the bounding boxes that nodes of different + connected components will have when they are placed next to each + other. "]], - examples = {[[" - \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, - components go right top aligned, - component sep=1pt, nodes=draw] - { - 1 -> 2 -> {3->4[second]->5,6,7}; - a -> b[second] -> c[second] -> d -> e; - x -> y[second] -> z -> u[second] -> v; - }; - "]],[[" - \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, - components go right top aligned, - component sep=1em, nodes=draw] - { - 1 -> 2 -> {3->4[second]->5,6,7}; - a -> b[second] -> c[second] -> d -> e; - x -> y[second] -> z -> u[second] -> v; - }; - "]] - } + examples = { + [[" + \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, + components go right top aligned, + component sep=1pt, nodes=draw] + { + 1 -> 2 -> {3->4[second]->5,6,7}; + a -> b[second] -> c[second] -> d -> e; + x -> y[second] -> z -> u[second] -> v; + }; + "]], + [[" + \tikz \graph [binary tree layout, sibling distance=4mm, level distance=8mm, + components go right top aligned, + component sep=1em, nodes=draw] + { + 1 -> 2 -> {3->4[second]->5,6,7}; + a -> b[second] -> c[second] -> d -> e; + x -> y[second] -> z -> u[second] -> v; + }; + "]] + } } @@ -444,11 +451,11 @@ declare { initial = "2cm", summary = [[" - This is the minimum distance between the centers of bounding - boxes of connected components when they are placed next to each - other. (Not used, currently.) + This is the minimum distance between the centers of bounding + boxes of connected components when they are placed next to each + other. (Not used, currently.) "]] } -return Distances +return Distances
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua index 87d67b5b56f..be1666b255b 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/FineTune.lua @@ -28,20 +28,20 @@ declare { type = "canvas coordinate", summary = [[" - This option allows you to slightly ``nudge'' (move) nodes after - they have been positioned by the given offset. The idea is that - this nudging is done after the position of the node has been - computed, so nudging has no influence on the actual graph - drawing algorithms. This, in turn, means that you can use - nudging to ``correct'' or ``optimize'' the positioning of nodes - after the algorithm has computed something. + This option allows you to slightly ``nudge'' (move) nodes after + they have been positioned by the given offset. The idea is that + this nudging is done after the position of the node has been + computed, so nudging has no influence on the actual graph + drawing algorithms. This, in turn, means that you can use + nudging to ``correct'' or ``optimize'' the positioning of nodes + after the algorithm has computed something. "]], examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge=(up:2mm)]} -- e -- a; - }; + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge=(up:2mm)]} -- e -- a; + }; "]] } @@ -58,10 +58,10 @@ declare { summary = "A shorthand for nudging a node upwards.", examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge up=2mm]} -- e -- a; - }; + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge up=2mm]} -- e -- a; + }; "]] } @@ -91,10 +91,10 @@ declare { summary = "Like |nudge up|, but left.", examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b, c, d[nudge left=2mm]} -- e -- a; - }; + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b, c, d[nudge left=2mm]} -- e -- a; + }; "]] } @@ -118,18 +118,18 @@ declare { type = "canvas coordinate", summary = [[" - Using this option you can provide a position for a node to wish - it will be forced after the graph algorithms have run. So, the node - is positioned normally and the graph drawing algorithm does not know - about the position specified using |regardless at|. However, - afterwards, the node is placed there, regardless of what the - algorithm has computed (all other nodes are unaffected). + Using this option you can provide a position for a node to wish + it will be forced after the graph algorithms have run. So, the node + is positioned normally and the graph drawing algorithm does not know + about the position specified using |regardless at|. However, + afterwards, the node is placed there, regardless of what the + algorithm has computed (all other nodes are unaffected). "]], examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b,c,d[regardless at={(1,0)}]} -- e -- a; - }; + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b,c,d[regardless at={(1,0)}]} -- e -- a; + }; "]] } @@ -148,17 +148,17 @@ declare { }, summary = [[" - This option combines |desired at| and |regardless at|. Thus, the - algorithm is ``told'' about the desired position. If it fails to place - the node at the desired position, it will be put there - regardless. The name of the key is intended to remind one of a node - being ``nailed'' to the canvas. + This option combines |desired at| and |regardless at|. Thus, the + algorithm is ``told'' about the desired position. If it fails to place + the node at the desired position, it will be put there + regardless. The name of the key is intended to remind one of a node + being ``nailed'' to the canvas. "]], examples = [[" - \tikz \graph [edges=rounded corners, nodes=draw, - layered layout, sibling distance=0] { - a -- {b,c,d[nail at={(1,0)}]} -- e[nail at={(1.5,-1)}] -- a; - }; + \tikz \graph [edges=rounded corners, nodes=draw, + layered layout, sibling distance=0] { + a -- {b,c,d[nail at={(1,0)}]} -- e[nail at={(1.5,-1)}] -- a; + }; "]] } diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/LayoutPipeline.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/LayoutPipeline.lua index 1c5e48b4c7e..c998ca490aa 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/LayoutPipeline.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/LayoutPipeline.lua @@ -21,48 +21,48 @@ -- Before an algorithm is applied, a number of transformations will -- have been applied, depending on the algorithm's |preconditions| -- field: --- % +-- -- \begin{itemize} --- \item |connected| +-- \item |connected| -- --- If this property is set for an algorithm (that is, in the --- |declare| statement for the algorithm the |predconditions| field --- has the entry |connected=true| set), then the graph will be --- decomposed into connected components. The algorithm is run on each --- component individually. --- \item |tree| +-- If this property is set for an algorithm (that is, in the +-- |declare| statement for the algorithm the |predconditions| field +-- has the entry |connected=true| set), then the graph will be +-- decomposed into connected components. The algorithm is run on each +-- component individually. +-- \item |tree| -- --- When set, the field |spanning_tree| of the algorithm will be set --- to a spanning tree of the graph. This option implies |connected|. --- \item |loop_free| +-- When set, the field |spanning_tree| of the algorithm will be set +-- to a spanning tree of the graph. This option implies |connected|. +-- \item |loop_free| -- --- When set, all loops (arcs from a vertex to itself) will have been --- removed when the algorithm runs. +-- When set, all loops (arcs from a vertex to itself) will have been +-- removed when the algorithm runs. -- --- \item |at_least_two_nodes| +-- \item |at_least_two_nodes| -- --- When explicitly set to |false| (this precondition is |true| by --- default), the algorithm will even be run if there is only a --- single vertex in the graph. +-- When explicitly set to |false| (this precondition is |true| by +-- default), the algorithm will even be run if there is only a +-- single vertex in the graph. -- \end{itemize} -- -- Once the algorithm has run, the algorithm's |postconditions| will -- be processed: --- % +-- -- \begin{itemize} --- \item |upward_oriented| +-- \item |upward_oriented| -- --- When set, the algorithm tells the layout pipeline that the graph --- has been laid out in a layered manner with each layer going from --- left to right and layers at a whole going upwards (positive --- $y$-coordinates). The graph will then be rotated and possibly --- swapped in accordance with the |grow| key set by the user. --- \item |fixed| +-- When set, the algorithm tells the layout pipeline that the graph +-- has been laid out in a layered manner with each layer going from +-- left to right and layers at a whole going upwards (positive +-- $y$-coordinates). The graph will then be rotated and possibly +-- swapped in accordance with the |grow| key set by the user. +-- \item |fixed| -- --- When set, no rotational postprocessing will be done after the --- algorithm has run. Usually, a graph is rotated to meet a user's --- |orient| settings. However, when the algorithm has already --- ``ideally'' rotated the graph, set this postcondition. +-- When set, no rotational postprocessing will be done after the +-- algorithm has run. Usually, a graph is rotated to meet a user's +-- |orient| settings. However, when the algorithm has already +-- ``ideally'' rotated the graph, set this postcondition. -- \end{itemize} -- -- @@ -71,22 +71,23 @@ -- posttransformations. This happens when users install additional -- algorithms in appropriate phases. In detail, the following happens -- in order: --- % +-- -- \begin{enumerate} --- \item If specified, the graph is decomposed into connected --- components and the following steps are applied to each component --- individually. --- \item All algorithms in the phase stack for the phase --- |preprocessing| are applied to the component. These algorithms are --- run one after the other in the order they appear in the phase stack. --- \item If necessary, the spanning tree is now computed and --- rotational information is gathered. --- \item The single algorithm in phase |main| is called. --- \item All algorithms in the phase stack for the phase --- |edge routing| are run. --- \item All algorithms in the phase stack for phase |postprocessing| --- are run. --- \item Edge syncing, orientation, and anchoring are applied. +-- \item If specified, the graph is decomposed into connected +-- components and the following steps are applied to each component +-- individually. +-- \item All algorithms in the phase stack for the phase +-- |preprocessing| are applied to the component. These algorithms are +-- run one after the other in the order they appear in the phase +-- stack. +-- \item If necessary, the spanning tree is now computed and +-- rotational information is gathered. +-- \item The single algorithm in phase |main| is called. +-- \item All algorithms in the phase stack for the phase +-- |edge routing| are run. +-- \item All algorithms in the phase stack for phase |postprocessing| +-- are run. +-- \item Edge syncing, orientation, and anchoring are applied. -- \end{enumerate} -- -- If sublayouts are used, all of the above (except for anchoring) @@ -127,39 +128,39 @@ local prepare_events --- The main ``graph drawing pipeline'' that handles the pre- and --- postprocessing for a graph. This method is called by the display --- interface. +-- The main ``graph drawing pipeline'' that handles the pre- and +-- postprocessing for a graph. This method is called by the diplay +-- interface. -- -- @param scope A graph drawing scope. function LayoutPipeline.run(scope) -- The pipeline... - + -- Step 1: Preparations - + -- Prepare events prepare_events(scope.events) - + -- Step 2: Recursively layout the graph, starting with the root layout local root_layout = assert(scope.collections[InterfaceCore.sublayout_kind][1], "no layout in scope") - + scope.syntactic_digraph = Sublayouts.layoutRecursively (scope, - root_layout, - LayoutPipeline.runOnLayout, - { root_layout }) - + root_layout, + LayoutPipeline.runOnLayout, + { root_layout }) + -- Step 3: Anchor the graph LayoutPipeline.anchor(scope.syntactic_digraph, scope) - + -- Step 4: Apply regardless transforms Sublayouts.regardless(scope.syntactic_digraph) - + -- Step 5: Cut edges LayoutPipeline.cutEdges(scope.syntactic_digraph) - + end @@ -173,7 +174,7 @@ end -- @param algorithm_class The to-be-applied algorithm class. -- @param layout_graph A subgraph of the syntactic digraph which is -- restricted to the current layout and in which sublayouts have --- been contracted to single nodes. +-- been contracted to single nodes. -- @param layout The layout to which the graph belongs. -- function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout) @@ -188,12 +189,12 @@ function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout local new_a = layout_copy:connect(a.tail,a.head) new_a.syntactic_edges = a.syntactic_edges end - + -- Step 1: Decompose the graph into connected components, if necessary: local syntactic_components if algorithm_class.preconditions.tree or algorithm_class.preconditions.connected or layout_graph.options.componentwise then - syntactic_components = LayoutPipeline.decompose(layout_copy) - LayoutPipeline.sortComponents(layout_graph.options['component order'], syntactic_components) + syntactic_components = LayoutPipeline.decompose(layout_copy) + LayoutPipeline.sortComponents(layout_graph.options['component order'], syntactic_components) else -- Only one component: The graph itself... syntactic_components = { layout_copy } @@ -201,17 +202,17 @@ function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout -- Step 2: For all components do: for i,syntactic_component in ipairs(syntactic_components) do - + -- Step 2.1: Reset random number generator to make sure that the -- same graph is always typeset in the same way. - lib.randomseed(layout_graph.options['random seed']) - + math.randomseed(layout_graph.options['random seed']) + local digraph = Direct.digraphFromSyntacticDigraph(syntactic_component) -- Step 2.3: If requested, remove loops if algorithm_class.preconditions.loop_free then for _,v in ipairs(digraph.vertices) do - digraph:disconnect(v,v) + digraph:disconnect(v,v) end end @@ -221,15 +222,15 @@ function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout -- Step 2.4a: Run preprocessor for _,class in ipairs(layout_graph.options.algorithm_phases["preprocessing stack"]) do class.new{ - digraph = digraph, - ugraph = ugraph, - scope = scope, - layout = layout, - layout_graph = layout_graph, - syntactic_component = syntactic_component, - }:run() + digraph = digraph, + ugraph = ugraph, + scope = scope, + layout = layout, + layout_graph = layout_graph, + syntactic_component = syntactic_component, + }:run() end - + -- Step 2.5: Create an algorithm object local algorithm = algorithm_class.new{ digraph = digraph, @@ -239,14 +240,14 @@ function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout layout_graph = layout_graph, syntactic_component = syntactic_component, } - + -- Step 2.7: Compute a spanning tree, if necessary if algorithm_class.preconditions.tree then local spanning_algorithm_class = syntactic_component.options.algorithm_phases["spanning tree computation"] algorithm.spanning_tree = - spanning_algorithm_class.new{ - ugraph = ugraph, - events = scope.events + spanning_algorithm_class.new{ + ugraph = ugraph, + events = scope.events }:run() end @@ -260,43 +261,43 @@ function LayoutPipeline.runOnLayout(scope, algorithm_class, layout_graph, layout or algorithm_class.preconditions.at_least_two_nodes == false then -- Main run of the algorithm: if algorithm_class.old_graph_model then - LayoutPipeline.runOldGraphModel(scope, digraph, algorithm_class, algorithm) + LayoutPipeline.runOldGraphModel(scope, digraph, algorithm_class, algorithm) else - algorithm:run () + algorithm:run () end end -- Step 2.9a: Run edge routers for _,class in ipairs(layout_graph.options.algorithm_phases["edge routing stack"]) do class.new{ - digraph = digraph, - ugraph = ugraph, - scope = scope, - layout = layout, - layout_graph = layout_graph, - syntactic_component = syntactic_component, - }:run() + digraph = digraph, + ugraph = ugraph, + scope = scope, + layout = layout, + layout_graph = layout_graph, + syntactic_component = syntactic_component, + }:run() end - + -- Step 2.9b: Run postprocessor for _,class in ipairs(layout_graph.options.algorithm_phases["postprocessing stack"]) do class.new{ - digraph = digraph, - ugraph = ugraph, - scope = scope, - layout = layout, - layout_graph = layout_graph, - syntactic_component = syntactic_component, - }:run() + digraph = digraph, + ugraph = ugraph, + scope = scope, + layout = layout, + layout_graph = layout_graph, + syntactic_component = syntactic_component, + }:run() end - + -- Step 2.10: Sync the graphs digraph:sync() ugraph:sync() if algorithm.spanning_tree then algorithm.spanning_tree:sync() end - + -- Step 2.11: Orient the graph LayoutPipeline.orient(algorithm.rotation_info, algorithm.postconditions, syntactic_component, scope) end @@ -316,7 +317,7 @@ end -- procedure described in -- Section~\ref{subsection-library-graphdrawing-anchoring}. These -- transformations are always performed. --- +-- -- @param graph A graph -- @param scope The scope @@ -324,7 +325,7 @@ function LayoutPipeline.anchor(graph, scope) -- Step 1: Find anchor node: local anchor_node - + local anchor_node_name = graph.options['anchor node'] if anchor_node_name then anchor_node = scope.node_names[anchor_node_name] @@ -336,10 +337,10 @@ function LayoutPipeline.anchor(graph, scope) lib.find (graph.vertices, function (v) return v.options['desired at'] end) or graph.vertices[1] end - + -- Sanity check assert(graph:contains(anchor_node), "anchor node is not in graph!") - + local desired = anchor_node.options['desired at'] or graph.options['anchor at'] local delta = desired - anchor_node.pos @@ -360,7 +361,7 @@ end --- -- This method tries to determine in which direction the graph is supposed to -- grow and in which direction the algorithm will grow the graph. These two --- pieces of information together produce a necessary rotation around some node. +-- pieces of information togehter produce a necessary rotation around some node. -- This rotation is returned in a table. -- -- Note that this method does not actually cause a rotation to happen; this is @@ -371,12 +372,12 @@ end -- @return A table containing the computed information. function LayoutPipeline.prepareRotateAround(postconditions, graph) - + -- Find the vertex from which we orient local swap = true local v,_,grow = lib.find (graph.vertices, function (v) return v.options["grow"] end) - + if not v and graph.options["grow"] then v,grow,swap = graph.vertices[1], graph.options["grow"], true end @@ -385,7 +386,7 @@ function LayoutPipeline.prepareRotateAround(postconditions, graph) v,_,grow = lib.find (graph.vertices, function (v) return v.options["grow'"] end) swap = false end - + if not v and graph.options["grow'"] then v,grow,swap = graph.vertices[1], graph.options["grow'"], false end @@ -393,15 +394,15 @@ function LayoutPipeline.prepareRotateAround(postconditions, graph) if not v then v, grow, swap = graph.vertices[1], -90, true end - + -- Now compute the rotation local info = {} local growth_direction = (postconditions.upward_oriented and 90) or (postconditions.upward_oriented_swapped and 90) - + if postconditions.upward_oriented_swapped then swap = not swap end - + if growth_direction == "fixed" then info.angle = 0 -- no rotation elseif growth_direction then @@ -415,9 +416,9 @@ function LayoutPipeline.prepareRotateAround(postconditions, graph) local other = lib.find_min( graph:outgoing(v), function (a) - if a.head ~= v and a:eventIndex() then - return a, a:eventIndex() - end + if a.head ~= v and a:eventIndex() then + return a, a:eventIndex() + end end) info.to_node = (other and other.head) or (graph.vertices[1] == v and graph.vertices[2] or graph.vertices[1]) @@ -439,57 +440,55 @@ end -- orientation for what the algorithm assumes. -- -- The ``bounding box'' actually consists of the fields --- % -- \begin{itemize} --- \item |sibling_pre|, --- \item |sibling_post|, --- \item |layer_pre|, and --- \item |layer_post|, +-- \item |sibling_pre|, +-- \item |sibling_post|, +-- \item |layer_pre|, and +-- \item |layer_post|, -- \end{itemize} --- % -- which correspond to ``min x'', ``min y'', ``min y'', and ``max y'' --- for a tree growing up. +-- for a tree growing up. -- -- The computation of the ``bounding box'' treats a centered circle in -- a special way, all other shapes are currently treated like a -- rectangle. -- -- @param rotation_info The table computed by the function prepareRotateAround --- @param packing_storage A storage in which the computed distances are stored. --- @param graph An graph +-- @param packing_storage A storage in which the computed distances are stored. +-- @param graph An graph -- @param vertices An array of to-be-prepared vertices inside graph function LayoutPipeline.prepareBoundingBoxes(rotation_info, adjusted_bb, graph, vertices) - + local angle = assert(rotation_info.angle, "angle field missing") local swap = rotation_info.swap - + for _,v in ipairs(vertices) do local bb = adjusted_bb[v] local a = angle - + if v.shape == "circle" then a = 0 -- no rotation for circles. end - + -- Fill the bounding box field, bb.sibling_pre = math.huge bb.sibling_post = -math.huge bb.layer_pre = math.huge bb.layer_post = -math.huge - + local c = math.cos(angle) local s = math.sin(angle) for _,p in ipairs(v.path:coordinates()) do local x = p.x*c + p.y*s local y = -p.x*s + p.y*c - + bb.sibling_pre = math.min (bb.sibling_pre, x) bb.sibling_post = math.max (bb.sibling_post, x) bb.layer_pre = math.min (bb.layer_pre, y) bb.layer_post = math.max (bb.layer_post, y) end - + -- Flip sibling per and post if flag: if swap then bb.sibling_pre, bb.sibling_post = -bb.sibling_post, -bb.sibling_pre @@ -502,7 +501,7 @@ end -- --- Rotate the whole graph around a point +-- Rotate the whole graph around a point -- -- Causes the graph to be rotated around \meta{around} so that what -- used to be the |from_angle| becomes the |to_angle|. If the flag |swap| @@ -517,21 +516,21 @@ end -- swapped (flipped) along the new angle function LayoutPipeline.rotateGraphAround(graph, around_x, around_y, from, to, swap) - + -- Translate to origin local t = Transform.new_shift(-around_x, -around_y) - + -- Rotate to zero degrees: t = Transform.concat(Transform.new_rotation(-from), t) - + -- Swap if swap then t = Transform.concat(Transform.new_scaling(1,-1), t) end - + -- Rotate to from degrees: t = Transform.concat(Transform.new_rotation(to), t) - + -- Translate back t = Transform.concat(Transform.new_shift(around_x, around_y), t) @@ -547,7 +546,7 @@ end --- +-- -- Orient the whole graph using two nodes -- -- The whole graph is rotated so that the line from the first node to @@ -558,17 +557,17 @@ end -- @param first_node -- @param seond_node -- @param target_angle --- @param swap +-- @param swap function LayoutPipeline.orientTwoNodes(graph, first_node, second_node, target_angle, swap) if first_node and second_node then -- Compute angle between first_node and second_node: local x = second_node.pos.x - first_node.pos.x local y = second_node.pos.y - first_node.pos.y - + local angle = math.atan2(y,x) LayoutPipeline.rotateGraphAround(graph, first_node.pos.x, - first_node.pos.y, angle, target_angle, swap) + first_node.pos.y, angle, target_angle, swap) end end @@ -577,25 +576,25 @@ end --- -- Performs a post-layout orientation of the graph by performing the -- steps documented in Section~\ref{subsection-library-graphdrawing-standard-orientation}. --- +-- -- @param rotation_info The info record computed by the function |prepareRotateAround|. -- @param postconditions The algorithm's postconditions. -- @param graph A to-be-oriented graph. -- @param scope The graph drawing scope. function LayoutPipeline.orient(rotation_info, postconditions, graph, scope) - + -- Sanity check if #graph.vertices < 2 then return end - + -- Step 1: Search for global graph orient options: local function f (orient, tail, head, flag) if orient and head and tail then local n1 = scope.node_names[tail] local n2 = scope.node_names[head] if graph:contains(n1) and graph:contains(n2) then - LayoutPipeline.orientTwoNodes(graph, n1, n2, orient/360*2*math.pi, flag) - return true + LayoutPipeline.orientTwoNodes(graph, n1, n2, orient/360*2*math.pi, flag) + return true end end end @@ -609,32 +608,32 @@ function LayoutPipeline.orient(rotation_info, postconditions, graph, scope) if f(-90, tail, head, false) then return end local tail, head = string.match(graph.options["vertical'"] or "", "^(.*) to (.*)$") if f(-90, tail, head, true) then return end - + -- Step 2: Search for a node with the orient option: for _, v in ipairs(graph.vertices) do local function f (key, flag) local orient = v.options[key] - local head = v.options["orient head"] + local head = v.options["orient head"] local tail = v.options["orient tail"] - + if orient and head then - local n2 = scope.node_names[head] - if graph:contains(n2) then - LayoutPipeline.orientTwoNodes(graph, v, n2, orient/360*2*math.pi, flag) - return true - end - elseif orient and tail then - local n1 = scope.node_names[tail] - if graph:contains(n1) then - LayoutPipeline.orientTwoNodes(graph, n1, v, orient/360*2*math.pi, flag) - return true - end + local n2 = scope.node_names[head] + if graph:contains(n2) then + LayoutPipeline.orientTwoNodes(graph, v, n2, orient/360*2*math.pi, flag) + return true + end + elseif orient and tail then + local n1 = scope.node_names[tail] + if graph:contains(n1) then + LayoutPipeline.orientTwoNodes(graph, n1, v, orient/360*2*math.pi, flag) + return true + end end end if f("orient", false) then return end if f("orient'", true) then return end end - + -- Step 3: Search for an edge with the orient option: for _, a in ipairs(graph.arcs) do if a:options("orient",true) then @@ -644,21 +643,21 @@ function LayoutPipeline.orient(rotation_info, postconditions, graph, scope) return LayoutPipeline.orientTwoNodes(graph, a.tail, a.head, a:options("orient'")/360*2*math.pi, true) end end - + -- Step 4: Search two nodes with a desired at option: local first, second, third - + for _, v in ipairs(graph.vertices) do if v.options['desired at'] then if first then - if second then - third = v - break - else - second = v - end - else - first = v + if second then + third = v + break + else + second = v + end + else + first = v end end end @@ -668,13 +667,13 @@ function LayoutPipeline.orient(rotation_info, postconditions, graph, scope) local b = second.options['desired at'] return LayoutPipeline.orientTwoNodes(graph, first, second, math.atan2(b.y-a.y,b.x-a.x), false) end - + -- Computed during preprocessing: if rotation_info.from_node and postconditions.fixed ~= true then local x = rotation_info.from_node.pos.x local y = rotation_info.from_node.pos.y local from_angle = rotation_info.from_angle or math.atan2(rotation_info.to_node.pos.y - y, rotation_info.to_node.pos.x - x) - + LayoutPipeline.rotateGraphAround(graph, x, y, from_angle, rotation_info.to_angle, rotation_info.swap) end end @@ -690,74 +689,74 @@ end -- -- @param graph A to-be-decomposed graph -- --- @return An array of graph objects that represent the connected components of the graph. +-- @return An array of graph objects that represent the connected components of the graph. function LayoutPipeline.decompose (digraph) -- The list of connected components (node sets) local components = {} - + -- Remember, which graphs have already been visited local visited = {} - + for _,v in ipairs(digraph.vertices) do if not visited[v] then -- Start a depth-first-search of the graph, starting at node n: local stack = { v } local component = Digraph.new { - syntactic_digraph = digraph.syntactic_digraph, - options = digraph.options + syntactic_digraph = digraph.syntactic_digraph, + options = digraph.options } - + while #stack >= 1 do - local tos = stack[#stack] - stack[#stack] = nil -- pop - - if not visited[tos] then - - -- Visit pos: - component:add { tos } - visited[tos] = true - - -- Push all unvisited neighbors: - for _,a in ipairs(digraph:incoming(tos)) do - local neighbor = a.tail - if not visited[neighbor] then - stack[#stack+1] = neighbor -- push - end - end - for _,a in ipairs(digraph:outgoing(tos)) do - local neighbor = a.head - if not visited[neighbor] then - stack[#stack+1] = neighbor -- push - end - end - end + local tos = stack[#stack] + stack[#stack] = nil -- pop + + if not visited[tos] then + + -- Visit pos: + component:add { tos } + visited[tos] = true + + -- Push all unvisited neighbors: + for _,a in ipairs(digraph:incoming(tos)) do + local neighbor = a.tail + if not visited[neighbor] then + stack[#stack+1] = neighbor -- push + end + end + for _,a in ipairs(digraph:outgoing(tos)) do + local neighbor = a.head + if not visited[neighbor] then + stack[#stack+1] = neighbor -- push + end + end + end end - + -- Ok, vertices will now contain all vertices reachable from n. components[#components+1] = component end end - + if #components < 2 then return { digraph } end - + for _,c in ipairs(components) do table.sort (c.vertices, function (u,v) return u.event.index < v.event.index end) for _,v in ipairs(c.vertices) do for _,a in ipairs(digraph:outgoing(v)) do - local new_a = c:connect(a.tail, a.head) - new_a.syntactic_edges = a.syntactic_edges + local new_a = c:connect(a.tail, a.head) + new_a.syntactic_edges = a.syntactic_edges end for _,a in ipairs(digraph:incoming(v)) do - local new_a = c:connect(a.tail, a.head) - new_a.syntactic_edges = a.syntactic_edges + local new_a = c:connect(a.tail, a.head) + new_a.syntactic_edges = a.syntactic_edges end end end - + return components end @@ -785,23 +784,23 @@ end -- Right now, we hardcode the functions here. Perhaps make this -- dynamic in the future. Could easily be done on the tikzlayer, --- actually. +-- acutally. LayoutPipeline.component_ordering_functions = { - ["increasing node number"] = - function (g,h) + ["increasing node number"] = + function (g,h) if #g.vertices == #h.vertices then - return g.vertices[1].event.index < h.vertices[1].event.index + return g.vertices[1].event.index < h.vertices[1].event.index else - return #g.vertices < #h.vertices + return #g.vertices < #h.vertices end end, - ["decreasing node number"] = - function (g,h) + ["decreasing node number"] = + function (g,h) if #g.vertices == #h.vertices then - return g.vertices[1].event.index < h.vertices[1].event.index + return g.vertices[1].event.index < h.vertices[1].event.index else - return #g.vertices > #h.vertices + return #g.vertices > #h.vertices end end, ["by first specified node"] = nil, @@ -811,27 +810,27 @@ LayoutPipeline.component_ordering_functions = { local function compute_rotated_bb(vertices, angle, sep, bb) - + local r = Transform.new_rotation(-angle) - + for _,v in ipairs(vertices) do -- Find the rotated bounding box field, local t = Transform.concat(r,Transform.new_shift(v.pos.x, v.pos.y)) - + local min_x = math.huge local max_x = -math.huge local min_y = math.huge local max_y = -math.huge - + for _,e in ipairs(v.path) do if type(e) == "table" then - local c = e:clone() - c:apply(t) - - min_x = math.min (min_x, c.x) - max_x = math.max (max_x, c.x) - min_y = math.min (min_y, c.y) - max_y = math.max (max_y, c.y) + local c = e:clone() + c:apply(t) + + min_x = math.min (min_x, c.x) + max_x = math.max (max_x, c.x) + min_y = math.min (min_y, c.y) + max_y = math.max (max_y, c.y) end end @@ -840,12 +839,12 @@ local function compute_rotated_bb(vertices, angle, sep, bb) max_x = max_x + sep min_y = min_y - sep max_y = max_y + sep - + local _,_,_,_,c_x,c_y = v:boundingBox() local center = Coordinate.new(c_x,c_y) - + center:apply(t) - + bb[v].min_x = min_x bb[v].max_x = max_x bb[v].min_y = min_y @@ -856,9 +855,9 @@ end ---- +--- -- This internal function packs the components of a graph. See --- Section~\ref{subsection-gd-component-packing} for details. +-- Section~\ref{subsection-gd-component-packing} for details. -- -- @param graph The graph -- @param components A list of components @@ -867,14 +866,14 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) local vertices = Storage.newTableStorage() local bb = Storage.newTableStorage() - + -- Step 1: Preparation, rotation to target direction local sep = syntactic_digraph.options['component sep'] local angle = syntactic_digraph.options['component direction']/180*math.pi - + local mark = {} for _,c in ipairs(components) do - + -- Setup the lists of to-be-considered nodes local vs = {} for _,v in ipairs(c.vertices) do @@ -883,24 +882,24 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) for _,a in ipairs(c.arcs) do for _,p in ipairs(a:pointCloud()) do - vs [#vs + 1] = Vertex.new { pos = p } + vs [#vs + 1] = Vertex.new { pos = p } end end vertices[c] = vs compute_rotated_bb(vs, angle, sep/2, bb) end - + local x_shifts = { 0 } local y_shifts = {} - + -- Step 2: Vertical alignment for i,c in ipairs(components) do local max_max_y = -math.huge local max_center_y = -math.huge local min_min_y = math.huge local min_center_y = math.huge - + for _,v in ipairs(c.vertices) do local info = bb[v] max_max_y = math.max(info.max_y, max_max_y) @@ -908,7 +907,7 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) min_min_y = math.min(info.min_y, min_min_y) min_center_y = math.min(info.c_y, min_center_y) end - + -- Compute alignment line local valign = syntactic_digraph.options['component align'] local line @@ -922,15 +921,15 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) line = min_center_y elseif valign == "first node" then line = bb[c.vertices[1]].c_y - else + else line = min_min_y end - + -- Overruled? for _,v in ipairs(c.vertices) do if v.options['align here'] then - line = bb[v].c_y - break + line = bb[v].c_y + break end end @@ -957,9 +956,9 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) y_values[#y_values+1] = info.c_y end end - + table.sort(y_values) - + local y_ranks = {} local right_face = {} for i=1,#y_values do @@ -967,41 +966,41 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) right_face[i] = -math.huge end - - + + for i=1,#components-1 do -- First, update right_face: local touched = {} - + for _,v in ipairs(vertices[components[i]]) do local info = bb[v] local border = info.max_x - + for i=y_ranks[info.min_y],y_ranks[info.max_y] do - touched[i] = true - right_face[i] = math.max(right_face[i], border) + touched[i] = true + right_face[i] = math.max(right_face[i], border) end end - + -- Fill up the untouched entries: local right_max = -math.huge for i=1,#y_values do if not touched[i] then - -- Search for next and previous touched - local interpolate = -math.huge - for j=i+1,#y_values do - if touched[j] then - interpolate = math.max(interpolate,right_face[j] - (y_values[j] - y_values[i])) - break - end - end - for j=i-1,1,-1 do - if touched[j] then - interpolate = math.max(interpolate,right_face[j] - (y_values[i] - y_values[j])) - break - end - end - right_face[i] = math.max(interpolate,right_face[i]) + -- Search for next and previous touched + local interpolate = -math.huge + for j=i+1,#y_values do + if touched[j] then + interpolate = math.max(interpolate,right_face[j] - (y_values[j] - y_values[i])) + break + end + end + for j=i-1,1,-1 do + if touched[j] then + interpolate = math.max(interpolate,right_face[j] - (y_values[i] - y_values[j])) + break + end + end + right_face[i] = math.max(interpolate,right_face[i]) end right_max = math.max(right_max, right_face[i]) end @@ -1017,30 +1016,30 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) local border = info.min_x for i=y_ranks[info.min_y],y_ranks[info.max_y] do - touched[i] = true - left_face[i] = math.min(left_face[i], border) + touched[i] = true + left_face[i] = math.min(left_face[i], border) end end - + -- Fill up the untouched entries: local left_min = math.huge for i=1,#y_values do if not touched[i] then - -- Search for next and previous touched - local interpolate = math.huge - for j=i+1,#y_values do - if touched[j] then - interpolate = math.min(interpolate,left_face[j] + (y_values[j] - y_values[i])) - break - end - end - for j=i-1,1,-1 do - if touched[j] then - interpolate = math.min(interpolate,left_face[j] + (y_values[i] - y_values[j])) - break - end - end - left_face[i] = interpolate + -- Search for next and previous touched + local interpolate = math.huge + for j=i+1,#y_values do + if touched[j] then + interpolate = math.min(interpolate,left_face[j] + (y_values[j] - y_values[i])) + break + end + end + for j=i-1,1,-1 do + if touched[j] then + interpolate = math.min(interpolate,left_face[j] + (y_values[i] - y_values[j])) + break + end + end + left_face[i] = interpolate end left_min = math.min(left_min, left_face[i]) end @@ -1052,10 +1051,10 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) shift = right_max - left_min else for i=1,#y_values do - shift = math.max(shift, right_face[i] - left_face[i]) + shift = math.max(shift, right_face[i] - left_face[i]) end end - + -- Adjust nodes: x_shifts[i+1] = shift for _,v in ipairs(vertices[components[i+1]]) do @@ -1064,12 +1063,12 @@ function LayoutPipeline.packComponents(syntactic_digraph, components) info.max_x = info.max_x + shift end end - + -- Now, rotate shifts for i,c in ipairs(components) do local x = x_shifts[i]*math.cos(angle) - y_shifts[i]*math.sin(angle) local y = x_shifts[i]*math.sin(angle) + y_shifts[i]*math.cos(angle) - + for _,v in ipairs(vertices[c]) do v.pos.x = v.pos.x + x v.pos.y = v.pos.y + y @@ -1095,13 +1094,13 @@ prepare_events = for i=1,#events do if events[i].kind == "begin" then - stack[#stack + 1] = i + stack[#stack + 1] = i elseif events[i].kind == "end" then - local tos = stack[#stack] - stack[#stack] = nil -- pop - - events[tos].end_index = i - events[i].begin_index = tos + local tos = stack[#stack] + stack[#stack] = nil -- pop + + events[tos].end_index = i + events[i].begin_index = tos end end end @@ -1125,48 +1124,48 @@ function LayoutPipeline.cutEdges(graph) local p = e.path p:makeRigid() local orig = p:clone() - - if e.options['tail cut'] and e.tail.options['cut policy'] == "as edge requests" - or e.tail.options['cut policy'] == "all" then - - local vpath = e.tail.path:clone() - vpath:shiftByCoordinate(e.tail.pos) - - local x = p:intersectionsWith (vpath) - - if #x > 0 then - p:cutAtBeginning(x[1].index, x[1].time) - end + + if e.options['tail cut'] and e.tail.options['cut policy'] == "as edge requests" + or e.tail.options['cut policy'] == "all" then + + local vpath = e.tail.path:clone() + vpath:shiftByCoordinate(e.tail.pos) + + local x = p:intersectionsWith (vpath) + + if #x > 0 then + p:cutAtBeginning(x[1].index, x[1].time) + end end - - if e.options['head cut'] and e.head.options['cut policy'] == "as edge requests" - or e.head.options['cut policy'] == "all" then - - local vpath = e.head.path:clone() - vpath:shiftByCoordinate(e.head.pos) - x = p:intersectionsWith (vpath) - if #x > 0 then - p:cutAtEnd(x[#x].index, x[#x].time) - else - -- Check whether there was an intersection with the original - --path: - local x2 = orig:intersectionsWith (vpath) - if #x2 > 0 then - -- Ok, after cutting the tail vertex, there is no longer - -- an intersection with the head vertex, but there used to - -- be one. This means that the vertices overlap and the - -- path should be ``inside'' them. Hmm... - if e.options['allow inside edges'] and #p > 1 then - local from = p[2] - local to = x2[1].point - p:clear() - p:appendMoveto(from) - p:appendLineto(to) - else - p:clear() - end - end - end + + if e.options['head cut'] and e.head.options['cut policy'] == "as edge requests" + or e.head.options['cut policy'] == "all" then + + local vpath = e.head.path:clone() + vpath:shiftByCoordinate(e.head.pos) + x = p:intersectionsWith (vpath) + if #x > 0 then + p:cutAtEnd(x[#x].index, x[#x].time) + else + -- Check whether there was an intersection with the original + --path: + local x2 = orig:intersectionsWith (vpath) + if #x2 > 0 then + -- Ok, after cutting the tail vertex, there is no longer + -- an intersection with the head vertex, but there used to + -- be one. This means that the vertices overlap and the + -- path should be ``inside'' them. Hmm... + if e.options['allow inside edges'] and #p > 1 then + local from = p[2] + local to = x2[1].point + p:clear() + p:appendMoveto(from) + p:appendLineto(to) + else + p:clear() + end + end + end end end end @@ -1201,7 +1200,7 @@ local function compatibility_digraph_to_graph(scope, g) for i,e in ipairs(scope.events) do graph.events[i] = e end - + -- Nodes for _,v in ipairs(g.vertices) do if not v.name then @@ -1213,13 +1212,13 @@ local function compatibility_digraph_to_graph(scope, g) local node = Node.new{ name = v.name, tex = { - tex_node = v.tex and v.tex.stored_tex_box_number, - shape = v.shape, - minX = minX, - maxX = maxX, - minY = minY, - maxY = maxY, - }, + tex_node = v.tex and v.tex.stored_tex_box_number, + shape = v.shape, + minX = minX, + maxX = maxX, + minY = minY, + maxY = maxY, + }, options = v.options, event_index = v.event.index, index = v.event.index, @@ -1235,38 +1234,38 @@ local function compatibility_digraph_to_graph(scope, g) local da = g.syntactic_digraph:arc(a.tail, a.head) if da then for _,m in ipairs(da.syntactic_edges) do - if not mark[m] then - mark[m] = true - local from_node = graph:findNode(da.tail.name) - local to_node = graph:findNode(da.head.name) - local edge = graph:createEdge(from_node, to_node, m.direction, nil, m.options, nil) - edge.event_index = m.event.index - edge.orig_m = m - graph.events[m.event.index] = { kind = 'edge', parameters = edge } - end + if not mark[m] then + mark[m] = true + local from_node = graph:findNode(da.tail.name) + local to_node = graph:findNode(da.head.name) + local edge = graph:createEdge(from_node, to_node, m.direction, nil, m.options, nil) + edge.event_index = m.event.index + edge.orig_m = m + graph.events[m.event.index] = { kind = 'edge', parameters = edge } + end end end local da = g.syntactic_digraph:arc(a.head, a.tail) - if da then + if da then for _,m in ipairs(da.syntactic_edges) do - if not mark[m] then - mark[m] = true - local from_node = graph:findNode(da.tail.name) - local to_node = graph:findNode(da.head.name) - local edge = graph:createEdge(from_node, to_node, m.direction, nil, m.options, nil) - edge.event_index = m.event.index - edge.orig_m = m - graph.events[m.event.index] = { kind = 'edge', parameters = edge } - end + if not mark[m] then + mark[m] = true + local from_node = graph:findNode(da.tail.name) + local to_node = graph:findNode(da.head.name) + local edge = graph:createEdge(from_node, to_node, m.direction, nil, m.options, nil) + edge.event_index = m.event.index + edge.orig_m = m + graph.events[m.event.index] = { kind = 'edge', parameters = edge } + end end end end - + table.sort(graph.edges, function(e1,e2) return e1.event_index < e2.event_index end) for _,n in ipairs (graph.nodes) do table.sort(n.edges, function(e1,e2) return e1.event_index < e2.event_index end) end - + -- Clusters for _, c in ipairs(scope.collections['same layer'] or {}) do @@ -1275,7 +1274,7 @@ local function compatibility_digraph_to_graph(scope, g) graph:addCluster(cluster) for _,v in ipairs(c.vertices) do if g:contains(v) then - cluster:addNode(graph:findNode(v.name)) + cluster:addNode(graph:findNode(v.name)) end end end @@ -1293,7 +1292,7 @@ local function compatibility_graph_to_digraph(graph) if #e.bend_points > 0 then local c = {} for _,x in ipairs(e.bend_points) do - c[#c+1] = Coordinate.new (x.x, x.y) + c[#c+1] = Coordinate.new (x.x, x.y) end e.orig_m:setPolylinePath(c) end @@ -1310,12 +1309,12 @@ function LayoutPipeline.runOldGraphModel(scope, digraph, algorithm_class, algori algorithm.graph = graph graph:registerAlgorithm(algorithm) - + -- If requested, remove loops if algorithm_class.preconditions.loop_free then Simplifiers:removeLoopsOldModel(algorithm) end - + -- If requested, collapse multiedges if algorithm_class.preconditions.simple then Simplifiers:collapseMultiedgesOldModel(algorithm) @@ -1325,12 +1324,12 @@ function LayoutPipeline.runOldGraphModel(scope, digraph, algorithm_class, algori -- Main run of the algorithm: algorithm:run () end - + -- If requested, expand multiedges if algorithm_class.preconditions.simple then Simplifiers:expandMultiedgesOldModel(algorithm) end - + -- If requested, restore loops if algorithm_class.preconditions.loop_free then Simplifiers:restoreLoopsOldModel(algorithm) @@ -1344,4 +1343,4 @@ end -- Done -return LayoutPipeline +return LayoutPipeline
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua index 80aa7ef420a..e7d44d7d10e 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/NodeAnchors.lua @@ -18,9 +18,9 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- -- \label{section-gd-anchors} -- --- When a graph has been laid out completely, the edges between the +-- When a graph has been layed out completely, the edges between the -- nodes must be drawn. Conceptually, an edge is ``between two --- nodes'', but when we actually draw the node, we do not really want +-- nodes,'' but when we actually draw the node, we do not really want -- the edge's path to start ``in the middle'' of the node; rather, we -- want it to start ``on the border'' and also end there. -- @@ -37,7 +37,7 @@ local declare = require "pgf.gd.interface.InterfaceToAlgorithms".declare -- inside the tail and head nodes, respectively. The edge path will -- then start and end at these points, however, they will usually be -- shortened so that they actually start and end on the intersection --- of the edge's path with the nodes' paths. +-- of the edge's path with the nodes' paths. --- @@ -47,41 +47,41 @@ declare { type = "string", initial = "", - summary = [[" - Specifies where in the tail vertex the edge should start. + summary = [[" + Specifies where in the tail vertex the edge should start. "]], documentation = [[" - This is either a string or a number, interpreted as an angle - (with 90 meaning ``up''). If it is a string, when the start of - the edge is computed, we try to look up the anchor in the tail - vertex's table of anchors (some anchors get installed in this - table by the display system). If it is not found, we test - whether it is one of the special ``direction anchors'' like - |north| or |south east|. If so, we convert them into points on - the border of the node that lie in the direction of a line - starting at the center to a point on the bounding box of the - node in the designated direction. Finally, if the anchor is a - number, we use a point on the border of the node that is on a - line from the center in the specified direction. - - If the anchor is set to the empty string (which is the default), - the anchor is interpreted as the |center| anchor inside the - graph drawing system. However, a display system may choose to - make a difference between the |center| anchor and an empty - anchor (\tikzname\ does: for options like |bend left| if the - anchor is empty, the bend line starts at the border of the node, - while for the anchor set explicitly to |center| it starts at the - center). - - Note that graph drawing algorithms need not take the - setting of this option into consideration. However, the final - rendering of the edge will always take it into consideration - (only, the setting may not be very sensible if the algorithm - ignored it). + This is either a string or a number, interpreted as an angle + (with 90 meaning ``up''). If it is a string, when the start of + the edge is computed, we try to look up the anchor in the tail + vertex's table of anchors (some anchors get installed in this + table by the display system). If it is not found, we test + whether it is one of the special ``direction anchors'' like + |north| or |south east|. If so, we convert them into points on + the border of the node that lie in the direction of a line + starting at the center to a point on the bounding box of the + node in the designated direction. Finally, if the anchor is a + number, we use a point on the border of the node that is on a + line from the center in the specified direction. + + If the anchor is set to the empty string (which is the default), + the anchor is interpreted as the |center| anchor inside the + graph drawing system. However, a display system may choose to + make a difference between the |center| anchor and an empty + anchor (\tikzname\ does: for options like |bend left| if the + anchor is empty, the bend line starts at the border of the node, + while for the anchor set explicitly to |center| it starts at the + center). + + Note that graph drawing algorithms need not take the + setting of this option into consideration. However, the final + rendering of the edge will always take it into consideration + (only, the setting may not be very sensible if the algorithm + ignored it). "]] } - + --- declare { @@ -101,10 +101,10 @@ declare { initial = true, summary = [[" - Decides whether the tail of an edge is ``cut'', meaning - that the edge's path will be shortened at the beginning so that - it starts only of the node's border rather than at the exact - position of the |tail anchor|, which may be inside the node. + Decides whether the tail of an edge is ``cut'', meaning + that the edge's path will be shortened at the beginning so that + it starts only of the node's border rather than at the exact + position of the |tail anchor|, which may be inside the node. "]] } @@ -130,24 +130,23 @@ declare { summary = "The policy for cutting edges entering or leaving a node.", documentation = [[" - This option is important for nodes only. It can have three - possible values: - % - \begin{itemize} + This option is important for nodes only. It can have three + possible values: + \begin{itemize} \item |as edge requests| Whether or not an edge entering or - leaving the node is cut depends on the setting of the edge's - |tail cut| and |head cut| options. This is the default. + leaving the node is cut depends on the setting of the edge's + |tail cut| and |head cut| options. This is the default. \item |all| All edges entering or leaving the node are cut, - regardless of the edges' cut values. + regardless of the edges' cut values. \item |none| No edge entering or leaving the node is cut, - regardless of the edges' cut values. - \end{itemize} + regardless of the edges' cut values. + \end{itemize} "]] } - + --- -declare { +declare { key = "allow inside edges", type = "boolean", initial = "true", @@ -155,21 +154,21 @@ declare { summary = "Decides whether an edge between overlapping nodes should be drawn.", documentation = [[" - If two vertices overlap, it may happen that when you draw an - edge between them, this edges would be completely inside the two - vertices. In this case, one could either not draw them or one - could draw a sort of ``inside edge''. + If two vertices overlap, it may happen that when you draw an + edge between them, this edges would be completely inside the two + vertices. In this case, one could either not draw them or one + could draw a sort of ``inside edge''. "]], - + examples = { [[" - \tikz \graph [no layout, nodes={draw, minimum size=20pt}] { - a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] - }; - "]],[[" - \tikz \graph [no layout, nodes={draw, minimum size=20pt}, - allow inside edges=false] { - a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] - }; - "]] + \tikz \graph [no layout, nodes={draw, minimum size=20pt}] { + a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] + }; + "]], [[" + \tikz \graph [no layout, nodes={draw, minimum size=20pt}, + allow inside edges=false] { + a [x=0, y=0] -- b [x=15pt, y=10pt] -- c[x=40pt] + }; + "]] } }
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua index 1890fa4f39d..10f5ecdf471 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Orientation.lua @@ -27,7 +27,7 @@ -- you can specify that the line from a certain vertex to another -- vertex should have a certain slope. How these vertices and slopes -- are specified in explained momentarily. Second, you can specify a --- so-called ``growth direction'' for trees. +-- so-called ``growth direction'' for trees. -- -- @end @@ -48,40 +48,42 @@ declare { type = "direction", default = 0, - summary = [[" - This key specifies that the straight line from the |orient tail| to - the |orient head| should be at an angle of \meta{direction} relative to - the right-going $x$-axis. Which vertices are used as tail an head - depends on where the |orient| option is encountered: When used with - an edge, the tail is the edge's tail and the head is the edge's - head. When used with a node, the tail or the head must be specified - explicitly and the node is used as the node missing in the - specification. When used with a graph as a whole, both the head and - tail nodes must be specified explicitly. + summary = [[" + This key specifies that the straight line from the |orient tail| to + the |orient head| should be at an angle of \meta{direction} relative to + the right-going $x$-axis. Which vertices are used as tail an head + depends on where the |orient| option is encountered: When used with + an edge, the tail is the edge's tail und the head is the edge's + head. When used with a node, the tail or the head must be specified + explicitly and the node is used as the node missing in the + specification. When used with a graph as a whole, both the head and + tail nodes must be specified explicitly. "]], documentation = [[" - Note that the \meta{direction} is independent of the actual to-path - of an edge, which might define a bend or more complicated shapes. For - instance, a \meta{angle} of |45| requests that the end node is ``up - and right'' relative to the start node. - - You can also specify the standard direction texts |north| or |south east| - and so forth as \meta{direction} and also |up|, |down|, |left|, and - |right|. Also, you can specify |-| for ``right'' and \verb!|! for ``down''. - "]], - examples = {[[" - \tikz \graph [spring layout] - { - a -- { b, c, d, e -- {f, g, h} }; - h -- [orient=30] a; - }; - "]],[[" - \tikz \graph [spring layout] - { - a -- { b, c, d[> orient=right], e -- {f, g, h} }; - h -- a; - }; - "]] + Note that the \meta{direction} is independent of the actual to-path + of an edge, which might define a bend or more complicated shapes. For + instance, a \meta{angle} of |45| requests that the end node is ``up + and right'' relative to the start node. + + You can also specify the standard direction texts |north| or |south east| + and so forth as \meta{direction} and also |up|, |down|, |left|, and |right|. Also, you + can specify |-| for ``right'' and \verb!|! for ``down.'' + "]], + examples = { + [[" + \tikz \graph [spring layout] + { + a -- { b, c, d, e -- {f, g, h} }; + h -- [orient=30] a; + }; + "]], + [[" + \tikz \graph [spring layout] + { + a -- { b, c, d[> orient=right], e -- {f, g, h} }; + h -- a; + }; + "]] } } @@ -93,16 +95,16 @@ declare { type = "direction", default = 0, - summary = [[" - Same as |orient|, only the rest of the graph should be - flipped relative to the connection line. + summary = [[" + Same as |orient|, only the rest of the graph should be + flipped relative to the connection line. "]], examples = [[" - \tikz \graph [spring layout] - { - a -- { b, c, d[> orient'=right], e -- {f, g, h} }; - h -- a; - }; + \tikz \graph [spring layout] + { + a -- { b, c, d[> orient'=right], e -- {f, g, h} }; + h -- a; + }; "]] } @@ -112,24 +114,26 @@ declare { key = "orient tail", type = "string", - summary = [[" - Specifies the tail vertex for the orientation of a graph. See - |orient| for details. + summary = [[" + Specifies the tail vertex for the orientation of a graph. See + |orient| for details. "]], - examples = {[[" - \tikz \graph [spring layout] { - a [orient=|, orient tail=f] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [spring layout] { - a [orient=down, orient tail=h] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]] + examples = { + [[" + \tikz \graph [spring layout] { + a [orient=|, orient tail=f] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]], + [[" + \tikz \graph [spring layout] { + a [orient=down, orient tail=h] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]] } } - + @@ -140,21 +144,23 @@ declare { key = "orient head", type = "string", - summary = [[" - Specifies the head vertex for the orientation of a graph. See - |orient| for details. + summary = [[" + Specifies the head vertex for the orientation of a graph. See + |orient| for details. "]], - examples = {[[" - \tikz \graph [spring layout] - { - a [orient=|, orient head=f] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, orient=10, - orient tail=a, orient head=b] { a -- b -- c -- a }; - "]] + examples = { + [[" + \tikz \graph [spring layout] + { + a [orient=|, orient head=f] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]], + [[" + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, orient=10, + orient tail=a, orient head=b] { a -- b -- c -- a }; + "]] } } @@ -164,17 +170,17 @@ declare { key = "horizontal", type = "string", - summary = [[" - A shorthand for specifying |orient tail|, |orient head| and - |orient=0|. The tail will be everything before the part ``| to |'' - and the head will be everything following it. + summary = [[" + A shorthand for specifying |orient tail|, |orient head| and + |orient=0|. The tail will be everything before the part ``| to |'' + and the head will be everything following it. "]], - examples = [[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, horizontal=a to b] { a -- b -- c -- a }; + examples = [[" + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, horizontal=a to b] { a -- b -- c -- a }; "]] } - + @@ -184,11 +190,11 @@ declare { key = "horizontal'", type = "string", - summary = [[" - Like |horizontal|, but with a flip. + summary = [[" + Like |horizontal|, but with a flip. "]] } - + @@ -201,15 +207,16 @@ declare { key = "vertical", type = "string", - summary = [[" - A shorthand for specifying |orient tail|, |orient head| and |orient=-90|. + summary = [[" + A shorthand for specifying |orient tail|, |orient head| and + |orient=-90|. "]], examples = [[" - \tikz \graph [spring layout] { a -- b -- c -- a }; - \tikz \graph [spring layout, vertical=a to b] { a -- b -- c -- a }; + \tikz \graph [spring layout] { a -- b -- c -- a }; + \tikz \graph [spring layout, vertical=a to b] { a -- b -- c -- a }; "]] } - + @@ -220,8 +227,8 @@ declare { key = "vertical'", type = "string", - summary = [[" - Like |vertical|, but with a flip. + summary = [[" + Like |vertical|, but with a flip. "]] } @@ -233,50 +240,54 @@ declare { key = "grow", type = "direction", - summary = [[" - This key specifies in which direction the neighbors of a node - ``should grow''. For some graph drawing algorithms, especially for - those that layout trees, but also for those that produce layered - layouts, there is a natural direction in which the ``children'' of - a node should be placed. For instance, saying |grow=down| will cause - the children of a node in a tree to be placed in a left-to-right - line below the node (as always, you can replace the \meta{angle} - by direction texts). The children are requested to be placed in a - counter-clockwise fashion, the |grow'| key will place them in a - clockwise fashion. + summary = [[" + This key specifies in which direction the neighbors of a node + ``should grow.'' For some graph drawing algorithms, especially for + those that layout trees, but also for those that produce layered + layouts, there is a natural direction in which the ``children'' of + a node should be placed. For instance, saying |grow=down| will cause + the children of a node in a tree to be placed in a left-to-right + line below the node (as always, you can replace the \meta{angle} + by direction texts). The children are requested to be placed in a + counter-clockwise fashion, the |grow'| key will place them in a + clockwise fashion. "]], - documentation = [[" - Note that when you say |grow=down|, it is not necessarily the case - that any particular node is actually directly below the current - node; the key just requests that the direction of growth is downward. - - In principle, you can specify the direction of growth for each node - individually, but do not count on graph drawing algorithms to - honor these wishes. - - When you give the |grow=right| key to the graph as a whole, it will - be applied to all nodes. This happens to be exactly what you want: + documentation = [[" + Note that when you say |grow=down|, it is not necessarily the case + that any particular node is actually directly below the current + node; the key just requests that the direction of growth is + downward. + + In principle, you can specify the direction of growth for each node + individually, but do not count on graph drawing algorithms to + honour these wishes. + + When you give the |grow=right| key to the graph as a whole, it will + be applied to all nodes. This happens to be exactly what you want: "]], - examples = {[[" - \tikz \graph [layered layout, sibling distance=5mm] - { - a [grow=right] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz \graph [layered layout, grow=right, sibling distance=5mm] - { - a -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; - "]],[[" - \tikz - \graph [layered layout, grow=-80] - { - {a,b,c} --[complete bipartite] {e,d,f} - --[complete bipartite] {g,h,i}; - }; - "]] + examples = { + [[" + \tikz \graph [layered layout, sibling distance=5mm] + { + a [grow=right] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]], + [[" + \tikz \graph [layered layout, grow=right, sibling distance=5mm] + { + a -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; + "]], + [[" + \tikz + \graph [layered layout, grow=-80] + { + {a,b,c} --[complete bipartite] {e,d,f} + --[complete bipartite] {g,h,i}; + }; + "]] } } @@ -289,11 +300,11 @@ declare { summary = "Same as |grow|, only with the children in clockwise order.", examples = [[" - \tikz \graph [layered layout, sibling distance=5mm] - { - a [grow'=right] -- { b, c, d, e -- {f, g, h} }; - { h, g } -- a; - }; + \tikz \graph [layered layout, sibling distance=5mm] + { + a [grow'=right] -- { b, c, d, e -- {f, g, h} }; + { h, g } -- a; + }; "]] } diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Sublayouts.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Sublayouts.lua index 970483193f0..c28d12db563 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Sublayouts.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/Sublayouts.lua @@ -15,7 +15,7 @@ local function full_print(g, pref) for _,v in ipairs(g.vertices) do s = s .. tostring(v) .. "[" .. tostring(v.pos) .. "]\n " end - + s = s .. "\n" for _,a in ipairs(g.arcs) do @@ -23,16 +23,16 @@ local function full_print(g, pref) s = s .. tostring(e) .. "(" .. tostring(e.path) .. ")\n" end end - + pgf.debug((pref or "") .. s) end --- --- The |Sublayouts| module handles graphs for which multiple layouts are defined. +-- The |Sublayouts| module handles graphs for which multiple layouts are defined. -- -- Please see Section~\ref{section-gd-sublayouts} for an overview of --- sublayouts. +-- sublayouts. -- local Sublayouts = {} @@ -80,7 +80,7 @@ end -- Nudge positioning. You can call this function several times on the --- same graph; nudging will be done only once. +-- same graph; nudging will be done only once. -- -- @param graph A graph -- @@ -100,28 +100,28 @@ end -- -- @param scope A scope -- @param syntactic_digraph The syntactic digraph. --- @param test Only for vertices whose subgraph collection passes this test will we create subgraph nodes +-- @param test Only for vertices whose subgraph collection passes this test will we create subgraph nodes local function create_subgraph_node(scope, syntactic_digraph, vertex) - + local subgraph_collection = vertex.subgraph_collection local binding = InterfaceCore.binding - + local cloud = {} -- Add all points of n's collection, except for v itself, to the cloud: for _,v in ipairs(subgraph_collection.vertices) do if vertex ~= v then assert(syntactic_digraph:contains(v), "the layout must contain all nodes of the subgraph") for _,p in ipairs(v.path) do - if type(p) == "table" then - cloud[#cloud+1] = p + v.pos - end + if type(p) == "table" then + cloud[#cloud+1] = p + v.pos + end end end end for _,e in ipairs(subgraph_collection.edges) do for _,p in ipairs(e.path) do if type(p) == "table" then - cloud[#cloud+1] = p:clone() + cloud[#cloud+1] = p:clone() end end end @@ -137,13 +137,13 @@ local function create_subgraph_node(scope, syntactic_digraph, vertex) o[#o+1] = { key = "subgraph point cloud", value = table.concat(lib.imap(cloud, tostring)) } o[#o+1] = { key = "subgraph bounding box height", value = tostring(y_max-y_min) .. "pt" } o[#o+1] = { key = "subgraph bounding box width", value = tostring(x_max-x_min) .. "pt" } - + -- And now, the "grand call": binding:createVertex(vertex.subgraph_info) - + -- Shift it were it belongs vertex.pos:shift(c_x,c_y) - + -- Remember all the subnodes for nudging and regardless -- positioning local s = {} @@ -191,22 +191,22 @@ end -- @return A laid out graph. function Sublayouts.layoutRecursively(scope, layout, fun) - + -- Step 1: Iterate over all sublayouts of the current layout: local resulting_graphs = {} local loc = Storage.new() - + -- Now, iterate over all sublayouts for i,child in ipairs(layout:childrenOfKind(InterfaceCore.sublayout_kind)) do resulting_graphs[i] = Sublayouts.layoutRecursively(scope, child, fun) loc[resulting_graphs[i]] = child end - + -- Step 2: Run the merge process: local merged_graphs = {} - + while #resulting_graphs > 0 do - + local n = #resulting_graphs -- Setup marked array: @@ -214,57 +214,57 @@ function Sublayouts.layoutRecursively(scope, layout, fun) for i=1,n do marked[i] = false end - + -- Mark first graph and copy everything from there marked[1] = true local touched = Storage.new() for _,v in ipairs(resulting_graphs[1].vertices) do v.pos = positions[v][resulting_graphs[1]] touched[v] = true - end + end -- Repeatedly find a node that is connected to a marked node: local i = 1 while i <= n do if not marked[i] then - for j=1,n do - if marked[j] then - local v = intersection(resulting_graphs[i], resulting_graphs[j]) - if v then - -- Aha, they intersect at vertex v - - -- Mark the i-th graph: - marked[i] = true - connected_some_graph = true - - -- Shift the i-th graph: - local x_offset = v.pos.x - positions[v][resulting_graphs[i]].x - local y_offset = v.pos.y - positions[v][resulting_graphs[i]].y - - for _,u in ipairs(resulting_graphs[i].vertices) do - if not touched[u] then - touched[u] = true - u.pos = positions[u][resulting_graphs[i]]:clone() - u.pos:shift(x_offset, y_offset) - - for _,a in ipairs(resulting_graphs[i]:outgoing(u)) do - for _,e in ipairs(a.syntactic_edges) do - for _,p in ipairs(e.path) do - if type(p) == "table" then - p:shift(x_offset, y_offset) - end - end - end - end - end - end - - -- Restart - i = 0 - break - end - end - end + for j=1,n do + if marked[j] then + local v = intersection(resulting_graphs[i], resulting_graphs[j]) + if v then + -- Aha, they intersect at vertex v + + -- Mark the i-th graph: + marked[i] = true + connected_some_graph = true + + -- Shift the i-th graph: + local x_offset = v.pos.x - positions[v][resulting_graphs[i]].x + local y_offset = v.pos.y - positions[v][resulting_graphs[i]].y + + for _,u in ipairs(resulting_graphs[i].vertices) do + if not touched[u] then + touched[u] = true + u.pos = positions[u][resulting_graphs[i]]:clone() + u.pos:shift(x_offset, y_offset) + + for _,a in ipairs(resulting_graphs[i]:outgoing(u)) do + for _,e in ipairs(a.syntactic_edges) do + for _,p in ipairs(e.path) do + if type(p) == "table" then + p:shift(x_offset, y_offset) + end + end + end + end + end + end + + -- Restart + i = 0 + break + end + end + end end i = i + 1 end @@ -273,19 +273,19 @@ function Sublayouts.layoutRecursively(scope, layout, fun) local merge = Digraph.new {} merge.syntactic_digraph = merge local remaining = {} - + -- Add all vertices and edges: for i=1,n do if marked[i] then - merge:add (resulting_graphs[i].vertices) - for _,a in ipairs(resulting_graphs[i].arcs) do - local ma = merge:connect(a.tail,a.head) - for _,e in ipairs(a.syntactic_edges) do - ma.syntactic_edges[#ma.syntactic_edges+1] = e - end - end - else - remaining[#remaining + 1] = resulting_graphs[i] + merge:add (resulting_graphs[i].vertices) + for _,a in ipairs(resulting_graphs[i].arcs) do + local ma = merge:connect(a.tail,a.head) + for _,e in ipairs(a.syntactic_edges) do + ma.syntactic_edges[#ma.syntactic_edges+1] = e + end + end + else + remaining[#remaining + 1] = resulting_graphs[i] end end @@ -294,37 +294,37 @@ function Sublayouts.layoutRecursively(scope, layout, fun) -- Restart with rest: merged_graphs[#merged_graphs+1] = merge - + resulting_graphs = remaining end - + -- Step 3: Run the algorithm on the layout: - - local class = layout.options.algorithm_phases.main + + local class = layout.options.algorithm_phases.main assert (type(class) == "table", "algorithm selection failed") - + local algorithm = class local uncollapsed_subgraph_nodes = lib.imap( scope.collections[InterfaceCore.subgraph_node_kind] or {}, function (c) if c.parent_layout == layout then - return c.subgraph_node + return c.subgraph_node end end) - + -- Create a new syntactic digraph: local syntactic_digraph = Digraph.new { options = layout.options } syntactic_digraph.syntactic_digraph = syntactic_digraph - + -- Copy all vertices and edges from the collection... syntactic_digraph:add (layout.vertices) for _,e in ipairs(layout.edges) do syntactic_digraph:add {e.head, e.tail} - local arc = syntactic_digraph:connect(e.tail, e.head) + local arc = syntactic_digraph:connect(e.tail, e.head) arc.syntactic_edges[#arc.syntactic_edges+1] = e end @@ -335,13 +335,13 @@ function Sublayouts.layoutRecursively(scope, layout, fun) -- Test, if all vertices of the subgraph are in one of the merged graphs. for _,g in ipairs(merged_graphs) do if special_vertex_subset(vertices, g) then - -- Ok, we can create a subgraph now - create_subgraph_node(scope, syntactic_digraph, v) - -- Make it part of the collapse! - g:add{v} - -- Do not consider again - uncollapsed_subgraph_nodes[i] = false - break + -- Ok, we can create a subgraph now + create_subgraph_node(scope, syntactic_digraph, v) + -- Make it part of the collapse! + g:add{v} + -- Do not consider again + uncollapsed_subgraph_nodes[i] = false + break end end end @@ -353,7 +353,7 @@ function Sublayouts.layoutRecursively(scope, layout, fun) local intersection = {} for _,v in ipairs(g.vertices) do if syntactic_digraph:contains(v) then - intersection[#intersection+1] = v + intersection[#intersection+1] = v end end if #intersection > 0 then @@ -361,33 +361,33 @@ function Sublayouts.layoutRecursively(scope, layout, fun) -- hull) Hmm...: local array = {} for _,v in ipairs(g.vertices) do - local min_x, min_y, max_x, max_y = v:boundingBox() - array[#array+1] = Coordinate.new(min_x + v.pos.x, min_y + v.pos.y) - array[#array+1] = Coordinate.new(max_x + v.pos.x, max_y + v.pos.y) + local min_x, min_y, max_x, max_y = v:boundingBox() + array[#array+1] = Coordinate.new(min_x + v.pos.x, min_y + v.pos.y) + array[#array+1] = Coordinate.new(max_x + v.pos.x, max_y + v.pos.y) end for _,a in ipairs(g.arcs) do - for _,e in ipairs(a.syntactic_edges) do - for _,p in ipairs(e.path) do - if type(p) == "table" then - array[#array+1] = p - end - end - end + for _,e in ipairs(a.syntactic_edges) do + for _,p in ipairs(e.path) do + if type(p) == "table" then + array[#array+1] = p + end + end + end end local x_min, y_min, x_max, y_max, c_x, c_y = Coordinate.boundingBox(array) -- Shift the graph so that it is centered on the origin: for _,v in ipairs(g.vertices) do - v.pos:unshift(c_x,c_y) + v.pos:unshift(c_x,c_y) end for _,a in ipairs(g.arcs) do - for _,e in ipairs(a.syntactic_edges) do - for _,p in ipairs(e.path) do - if type(p) == "table" then - p:unshift(c_x,c_y) - end - end - end + for _,e in ipairs(a.syntactic_edges) do + for _,p in ipairs(e.path) do + if type(p) == "table" then + p:unshift(c_x,c_y) + end + end + end end x_min = x_min - c_x @@ -398,33 +398,33 @@ function Sublayouts.layoutRecursively(scope, layout, fun) local index = loc[g].event.index local v = Vertex.new { - -- Standard stuff - shape = "none", - kind = "node", - path = Path.new { - "moveto", - x_min, y_min, - x_min, y_max, - x_max, y_max, - x_max, y_min, - "closepath" - }, - options = {}, - event = scope.events[index] + -- Standard stuff + shape = "none", + kind = "node", + path = Path.new { + "moveto", + x_min, y_min, + x_min, y_max, + x_max, y_max, + x_max, y_min, + "closepath" + }, + options = {}, + event = scope.events[index] } - + -- Update node_event scope.events[index].parameters = v - + local collapse_vertex = syntactic_digraph:collapse( - intersection, - v, - nil, - function (new_arc, arc) - for _,e in ipairs(arc.syntactic_edges) do - new_arc.syntactic_edges[#new_arc.syntactic_edges+1] = e - end - end) + intersection, + v, + nil, + function (new_arc, arc) + for _,e in ipairs(arc.syntactic_edges) do + new_arc.syntactic_edges[#new_arc.syntactic_edges+1] = e + end + end) syntactic_digraph:remove(intersection) collapsed_vertices[#collapsed_vertices+1] = collapse_vertex @@ -432,14 +432,14 @@ function Sublayouts.layoutRecursively(scope, layout, fun) end -- Sort the vertices - table.sort(syntactic_digraph.vertices, function(u,v) return u.event.index < v.event.index end) - + table.sort(syntactic_digraph.vertices, function(u,v) return u.event.index < v.event.index end) + -- Should we "hide" the subgraph nodes? local hidden_node if not algorithm.include_subgraph_nodes then local subgraph_nodes = lib.imap (syntactic_digraph.vertices, - function (v) if v.kind == "subgraph node" then return v end end) - + function (v) if v.kind == "subgraph node" then return v end end) + if #subgraph_nodes > 0 then hidden_node = Vertex.new {} syntactic_digraph:collapse(subgraph_nodes, hidden_node) @@ -457,36 +457,36 @@ function Sublayouts.layoutRecursively(scope, layout, fun) -- Ok, everything setup! Run the algorithm... fun(scope, algorithm, syntactic_digraph, layout) - + if hidden_node then syntactic_digraph:expand(hidden_node) end - + -- Now, we need to expand the collapsed vertices once more: for i=#collapsed_vertices,1,-1 do syntactic_digraph:expand( collapsed_vertices[i], function (c, v) - v.pos:shiftByCoordinate(c.pos) + v.pos:shiftByCoordinate(c.pos) end, function (a, v) - for _,e in ipairs(a.syntactic_edges) do - for _,p in ipairs(e.path) do - if type(p) == "table" then - p:shiftByCoordinate(v.pos) - end - end - end + for _,e in ipairs(a.syntactic_edges) do + for _,p in ipairs(e.path) do + if type(p) == "table" then + p:shiftByCoordinate(v.pos) + end + end + end end ) for _,a in ipairs(syntactic_digraph:outgoing(collapsed_vertices[i])) do for _,e in ipairs(a.syntactic_edges) do - for _,p in ipairs(e.path) do - if type(p) == "table" then - p:shiftByCoordinate(a.tail.pos) - p:unshiftByCoordinate(e.tail.pos) - end - end + for _,p in ipairs(e.path) do + if type(p) == "table" then + p:shiftByCoordinate(a.tail.pos) + p:unshiftByCoordinate(e.tail.pos) + end + end end end end @@ -498,16 +498,16 @@ function Sublayouts.layoutRecursively(scope, layout, fun) create_subgraph_node(scope, syntactic_digraph, uncollapsed_subgraph_nodes[i]) end end - + -- Now seems like a good time to nudge and do regardless positioning nudge(syntactic_digraph) - -- Step 5: Cleanup + -- Step 5: Cleanup -- Push the computed position into the storage: for _,v in ipairs(syntactic_digraph.vertices) do positions[v][syntactic_digraph] = v.pos:clone() end - + return syntactic_digraph end @@ -531,6 +531,6 @@ end --- Done +-- Done -return Sublayouts +return Sublayouts
\ No newline at end of file diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua index c7adfab830e..2d8317bd72d 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/doc.lua @@ -30,7 +30,6 @@ documentation Now, when you set this key for a single node of a graph, then, by shifting the graph around, this ``wish'' can obviously always be fulfill: -% \begin{codeexample}[] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -40,7 +39,6 @@ always be fulfill: }; \end{tikzpicture} \end{codeexample} -% \begin{codeexample}[] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -50,7 +48,6 @@ always be fulfill: }; \end{tikzpicture} \end{codeexample} -% Since the key's name is a bit long and since the many braces and parentheses are a bit cumbersome, there is a special support for this key inside a |graph|: The standard |/tikz/at| key is redefined @@ -60,7 +57,6 @@ specify an |at| position for a node whose position it to be computed by a graph drawing algorithm.) A nice side effect of this is that you can use the |x| and |y| keys (see Section~\ref{section-graphs-xy}) to specify desired positions: -% \begin{codeexample}[] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -70,7 +66,6 @@ Section~\ref{section-graphs-xy}) to specify desired positions: }; \end{tikzpicture} \end{codeexample} -% \begin{codeexample}[] \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); @@ -80,7 +75,7 @@ Section~\ref{section-graphs-xy}) to specify desired positions: }; \end{tikzpicture} \end{codeexample} - + A problem arises when two or more nodes have this key set, because then your ``desires'' for placement and the positions computed by the graph drawing algorithm may clash. Graph drawing algorithms are @@ -88,10 +83,10 @@ the graph drawing algorithm may clash. Graph drawing algorithms are ignore these desired positions since they will be taken care of in the so-called post-anchoring phase, see below. However, for some algorithms it makes a lot of sense to fix the positions of some -nodes and only compute the positions of the other nodes relative -to these nodes. For instance, for a |spring layout| it makes perfect -sense that some nodes are ``nailed to the canvas'' while other -nodes can ``move freely''. +nodes and only compute the positions +of the other nodes relative to these nodes. For instance, for a +|spring layout| it makes perfect sense that some nodes are +``nailed to the canvas'' while other nodes can ``move freely''. ]] example @@ -139,21 +134,19 @@ key "anchor node" summary [[ This option can be used with a graph to specify a node that -should be used for anchoring the whole graph. +should be used for anchoring the whole graph. ]] documentation [[ When this option is specified, after the layout has been computed, the whole graph will be shifted in such a way that the \meta{node name} is -either -% +either \begin{itemize} - \item at the current value of |anchor at| or - \item at the position that is specified in the form of a - |desired at| for the \meta{node name}. +\item at the current value of |anchor at| or +\item at the position that is specified in the form of a + |desired at| for the \meta{node name}. \end{itemize} -% Note how in the last example |c| is placed at |(1,1)| rather than |b| as would happen by default. ]] @@ -170,7 +163,7 @@ example [[ \begin{tikzpicture} \draw [help lines] (0,0) grid (3,2); - + \graph [layered layout, anchor node=c, edges=rounded corners] { a -- {b [x=1,y=1], c [x=1,y=1] } -- d -- a}; \end{tikzpicture} @@ -185,15 +178,15 @@ key "anchor at" summary [[ -The coordinate at which the graph should be anchored when no -explicit anchor is given for any node. The initial value is the origin. +The coordinate at which the graph should be anchored when no +explicit anchor is given for any node. The initial value is the origin. ]] example [[ \begin{tikzpicture} \draw [help lines] (0,0) grid (2,2); - + \graph [layered layout, edges=rounded corners, anchor at={(1,2)}] { a -- {b, c [anchor here] } -- d -- a}; \end{tikzpicture} @@ -223,7 +216,7 @@ example [[ \begin{tikzpicture} \draw [help lines] (0,0) grid (2,2); - + \graph [layered layout, edges=rounded corners] { a -- {b, c [anchor here] } -- d -- a}; \end{tikzpicture} diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua index df7ce68dd94..e25e0cd628e 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/control/library.lua @@ -38,29 +38,29 @@ declare { type = "boolean", summary = "Specifies, that nodes should be drawn behind the edges", - documentation = [[" - Once a graph drawing algorithm has determined positions for the nodes, - they are drawn \emph{before} the edges are drawn; after - all, it is hard to draw an edge between nodes when their positions - are not yet known. However, we typically want the nodes to be - rendered \emph{after} or rather \emph{on top} of the edges. For - this reason, the default behavior is that the nodes at their - final positions are collected in a box that is inserted into the - output stream only after the edges have been drawn -- which has - the effect that the nodes will be placed ``on top'' of the - edges. - - This behavior can be changed using this option. When the key is - invoked, nodes are placed \emph{behind} the edges. + documentation = [[" + Once a graph drawing algorithm has determined positions for the nodes, + they are drawn \emph{before} the edges are drawn; after + all, it is hard to draw an edge between nodes when their positions + are not yet known. However, we typically want the nodes to be + rendered \emph{after} or rather \emph{on top} of the edges. For + this reason, the default behaviour is that the nodes at their + final positions are collected in a box that is inserted into the + output stream only after the edges have been drawn -- which has + the effect that the nodes will be placed ``on top'' of the + edges. + + This behaviour can be changed using this option. When the key is + invoked, nodes are placed \emph{behind} the edges. "]], examples = [[" - \tikz \graph [simple necklace layout, nodes={draw,fill=white}, - nodes behind edges] - { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; + \tikz \graph [simple necklace layout, nodes={draw,fill=white}, + nodes behind edges] + { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; "]] -} - +} + --- declare { @@ -69,13 +69,13 @@ declare { { key = "nodes behind edges", value = "false" }, }, - summary = [[" - This is the default placement of edges: Behind the nodes. + summary = [[" + This is the default placemenet of edges: Behind the nodes. "]], examples = [[" - \tikz \graph [simple necklace layout, nodes={draw,fill=white}, - edges behind nodes] - { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; + \tikz \graph [simple necklace layout, nodes={draw,fill=white}, + edges behind nodes] + { subgraph K_n [n=7], 1 [regardless at={(0,-1)}] }; "]] } @@ -85,14 +85,14 @@ declare { type = "number", initial = "42", - summary = [[" - To ensure that the same is always shown in the same way when the - same algorithm is applied, the random is seed is reset on each call - of the graph drawing engine. To (possibly) get different results on - different runs, change this value. + summary = [[" + To ensure that the same is always shown in the same way when the + same algorithm is applied, the random is seed is reset on each call + of the graph drawing engine. To (possibly) get different results on + different runs, change this value. "]] } - + --- declare { @@ -111,42 +111,45 @@ declare { type = "number", initial = 1, - summary = [[" - Sets the ``weight'' of an edge or a node. For many algorithms, this - number tells the algorithm how ``important'' the edge or node is. - For instance, in a |layered layout|, an edge with a large |weight| - will be as short as possible. + summary = [[" + Sets the ``weight'' of an edge or a node. For many algorithms, this + number tells the algorithm how ``important'' the edge or node is. + For instance, in a |layered layout|, an edge with a large |weight| + will be as short as possible. "]], - examples = {[[" - \tikz \graph [layered layout] { - a -- {b,c,d} -- e -- a; - }; - "]],[[" - \tikz \graph [layered layout] { - a -- {b,c,d} -- e --[weight=3] a; - }; - "]] + examples = { + [[" + \tikz \graph [layered layout] { + a -- {b,c,d} -- e -- a; + }; + "]], + [[" + \tikz \graph [layered layout] { + a -- {b,c,d} -- e --[weight=3] a; + }; + "]] } } - - + + --- declare { key = "length", type = "length", initial = 1, - summary = [[" - Sets the ``length'' of an edge. Algorithms may take this value - into account when drawing a graph. - "]], - examples = {[[" - \tikz \graph [phylogenetic tree layout] { - a --[length=2] b --[length=1] {c,d}; - a --[length=3] e - }; + summary = [[" + Sets the ``length'' of an edge. Algorithms may take this value + into account when drawing a graph. "]], + examples = { + [[" + \tikz \graph [phylogenetic tree layout] { + a --[length=2] b --[length=1] {c,d}; + a --[length=3] e + }; + "]], } } @@ -158,24 +161,24 @@ declare { type = "number", initial = "0", - summary = [[" - The radius of a circular object used in graph drawing. + summary = [[" + The radius of a circular object used in graph drawing. "]] } - + --- - + declare { key = "no layout", algorithm = { run = function (self) - for _,v in ipairs(self.digraph.vertices) do - if v.options['desired at'] then - v.pos.x = v.options['desired at'].x - v.pos.y = v.options['desired at'].y - end - end + for _,v in ipairs(self.digraph.vertices) do + if v.options['desired at'] then + v.pos.x = v.options['desired at'].x + v.pos.y = v.options['desired at'].y + end + end end }, summary = "This layout does nothing.", } |