diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua index dd897fbe8ac..6988e7a3d9d 100644 --- a/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua +++ b/Master/texmf-dist/tex/generic/pgf/graphdrawing/lua/pgf/gd/layered.lua @@ -20,7 +20,7 @@ require("pgf.gd").layered = layered local lib = require "pgf.gd.lib" local Storage = require "pgf.gd.lib.Storage" --- +-- -- This file defines some basic functions to compute and/or set the -- ideal distances between nodes of any kind of layered drawing of a -- graph. @@ -30,7 +30,7 @@ local Storage = require "pgf.gd.lib.Storage" -- Compute the ideal distance between two siblings -- -- @param paddings A |Storage| object in which the computed distances --- (paddings) are stored. +-- (paddings) are stored. -- @param graph The graph object -- @param n1 The first node -- @param n2 The second node @@ -55,9 +55,9 @@ function layered.ideal_sibling_distance (paddings, graph, n1, n2) sep = (n1_is_node and lib.lookup_option('sibling post sep', n1, graph) or 0) + (n2_is_node and lib.lookup_option('sibling pre sep', n2, graph) or 0) end - - return math.max(ideal_distance, sep + - ((n1_is_node and paddings[n1].sibling_post) or 0) - + + return math.max(ideal_distance, sep + + ((n1_is_node and paddings[n1].sibling_post) or 0) - ((n2_is_node and paddings[n2].sibling_pre) or 0)) end @@ -88,7 +88,7 @@ function layered.baseline_distance (paddings, graph, l1, l2) if #l1 == 0 or #l2 == 0 then return 0 end - + local layer_distance = -math.huge local layer_pre_sep = -math.huge local layer_post_sep = -math.huge @@ -110,7 +110,7 @@ function layered.baseline_distance (paddings, graph, l1, l2) min_pre = math.min(min_pre, paddings[n].layer_pre) end end - + return math.max(layer_distance, layer_post_sep + layer_pre_sep + max_post - min_pre) end @@ -121,18 +121,18 @@ end -- -- @param layers A |Storage| object assigning layers to vertices. -- @param paddings A |Storage| object storing the computed distances --- (paddings). +-- (paddings). -- @param graph The graph in which the nodes reside function layered.arrange_layers_by_baselines (layers, paddings, graph) local layer_vertices = Storage.newTableStorage() - + -- Decompose into layers: for _,v in ipairs(graph.vertices) do table.insert(layer_vertices[layers[v]], v) end - + if #layer_vertices > 0 then -- sanity check -- Now compute ideal distances and store local height = 0 @@ -140,12 +140,12 @@ function layered.arrange_layers_by_baselines (layers, paddings, graph) for _,v in ipairs(layer_vertices[1]) do v.pos.y = 0 end - + for i=2,#layer_vertices do height = height + layered.baseline_distance(paddings, graph, layer_vertices[i-1], layer_vertices[i]) for _,v in ipairs(layer_vertices[i]) do - v.pos.y = height + v.pos.y = height end end end @@ -156,4 +156,4 @@ end -- Done -return layered
\ No newline at end of file +return layered |