elkrb 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +364 -0
- data/LICENSE +25 -0
- data/README.adoc +695 -557
- data/exe/elkrb +36 -2
- data/lib/elkrb/atomic_destination.rb +53 -0
- data/lib/elkrb/best_effort_write.rb +49 -0
- data/lib/elkrb/cli/layout_flag_options.rb +54 -0
- data/lib/elkrb/cli.rb +155 -82
- data/lib/elkrb/command_resolver.rb +186 -0
- data/lib/elkrb/commands/batch_command.rb +28 -5
- data/lib/elkrb/commands/convert_command.rb +22 -52
- data/lib/elkrb/commands/diagram_command.rb +234 -102
- data/lib/elkrb/commands/options_command.rb +87 -0
- data/lib/elkrb/commands/render_command.rb +6 -1
- data/lib/elkrb/commands/validate_command.rb +146 -91
- data/lib/elkrb/errors.rb +20 -1
- data/lib/elkrb/format_sniffer.rb +362 -0
- data/lib/elkrb/geometry/bezier.rb +14 -4
- data/lib/elkrb/geometry/point.rb +5 -6
- data/lib/elkrb/geometry/rectangle.rb +2 -2
- data/lib/elkrb/graph/deep_stringify_keys.rb +30 -0
- data/lib/elkrb/graph/edge.rb +89 -3
- data/lib/elkrb/graph/graph.rb +43 -15
- data/lib/elkrb/graph/label.rb +16 -2
- data/lib/elkrb/graph/node.rb +13 -2
- data/lib/elkrb/graph/node_constraints.rb +139 -8
- data/lib/elkrb/graph/normalize_option_keys.rb +39 -0
- data/lib/elkrb/graph/port.rb +29 -21
- data/lib/elkrb/graph/read_only_mapping.rb +21 -0
- data/lib/elkrb/graphviz_wrapper.rb +152 -44
- data/lib/elkrb/layout/algorithm_registry.rb +65 -8
- data/lib/elkrb/layout/algorithms/base_algorithm.rb +74 -74
- data/lib/elkrb/layout/algorithms/box.rb +47 -20
- data/lib/elkrb/layout/algorithms/disco.rb +150 -61
- data/lib/elkrb/layout/algorithms/fixed.rb +70 -10
- data/lib/elkrb/layout/algorithms/force.rb +145 -86
- data/lib/elkrb/layout/algorithms/layered/bk/aligner.rb +104 -0
- data/lib/elkrb/layout/algorithms/layered/bk/compactor.rb +87 -0
- data/lib/elkrb/layout/algorithms/layered/bk/view.rb +103 -0
- data/lib/elkrb/layout/algorithms/layered/bk_node_placer.rb +170 -0
- data/lib/elkrb/layout/algorithms/layered/components.rb +170 -0
- data/lib/elkrb/layout/algorithms/layered/crossing_minimizer.rb +306 -0
- data/lib/elkrb/layout/algorithms/layered/cycle_breaker.rb +118 -49
- data/lib/elkrb/layout/algorithms/layered/discovery_order.rb +75 -0
- data/lib/elkrb/layout/algorithms/layered/dummy_slot.rb +31 -0
- data/lib/elkrb/layout/algorithms/layered/layer_assigner.rb +188 -48
- data/lib/elkrb/layout/algorithms/layered/layer_constraints.rb +82 -0
- data/lib/elkrb/layout/algorithms/layered/layer_sweep.rb +195 -0
- data/lib/elkrb/layout/algorithms/layered/node_placer.rb +214 -36
- data/lib/elkrb/layout/algorithms/layered/orthogonal/gap_solver.rb +219 -0
- data/lib/elkrb/layout/algorithms/layered/orthogonal/hyper_edge_segment.rb +152 -0
- data/lib/elkrb/layout/algorithms/layered/orthogonal/junction_points.rb +58 -0
- data/lib/elkrb/layout/algorithms/layered/orthogonal/segment_order.rb +134 -0
- data/lib/elkrb/layout/algorithms/layered/orthogonal_router.rb +253 -0
- data/lib/elkrb/layout/algorithms/layered/port_order.rb +188 -0
- data/lib/elkrb/layout/algorithms/layered/port_spread.rb +42 -0
- data/lib/elkrb/layout/algorithms/layered.rb +548 -13
- data/lib/elkrb/layout/algorithms/libavoid.rb +951 -187
- data/lib/elkrb/layout/algorithms/mrtree.rb +585 -65
- data/lib/elkrb/layout/algorithms/radial.rb +188 -29
- data/lib/elkrb/layout/algorithms/random.rb +131 -17
- data/lib/elkrb/layout/algorithms/rectpacking.rb +28 -40
- data/lib/elkrb/layout/algorithms/spore_compaction.rb +57 -100
- data/lib/elkrb/layout/algorithms/spore_overlap.rb +78 -84
- data/lib/elkrb/layout/algorithms/stress.rb +391 -84
- data/lib/elkrb/layout/algorithms/topdown_packing.rb +95 -31
- data/lib/elkrb/layout/algorithms/vertiflex.rb +12 -47
- data/lib/elkrb/layout/constraints/alignment_constraint.rb +49 -12
- data/lib/elkrb/layout/constraints/base_constraint.rb +3 -15
- data/lib/elkrb/layout/constraints/constraint_processor.rb +9 -23
- data/lib/elkrb/layout/constraints/fixed_position_constraint.rb +22 -13
- data/lib/elkrb/layout/constraints/layer_constraint.rb +10 -33
- data/lib/elkrb/layout/constraints/relative_position_constraint.rb +94 -50
- data/lib/elkrb/layout/edge_router.rb +533 -337
- data/lib/elkrb/layout/hierarchical_processor.rb +19 -276
- data/lib/elkrb/layout/java_random.rb +59 -0
- data/lib/elkrb/layout/label_placer.rb +165 -157
- data/lib/elkrb/layout/layout_engine.rb +46 -23
- data/lib/elkrb/layout/node_index.rb +149 -0
- data/lib/elkrb/layout/polyomino/component_compactor.rb +138 -0
- data/lib/elkrb/layout/polyomino/footprint.rb +94 -0
- data/lib/elkrb/layout/polyomino/grid.rb +106 -0
- data/lib/elkrb/layout/polyomino/packer.rb +95 -0
- data/lib/elkrb/layout/polyomino/piece.rb +52 -0
- data/lib/elkrb/layout/port_constraint_processor.rb +131 -44
- data/lib/elkrb/layout/spore/body.rb +65 -0
- data/lib/elkrb/layout/spore/depth_first_compaction.rb +127 -0
- data/lib/elkrb/layout/spore/edge_cost.rb +69 -0
- data/lib/elkrb/layout/spore/gap.rb +76 -0
- data/lib/elkrb/layout/spore/geometry.rb +104 -0
- data/lib/elkrb/layout/spore/overlap_sweep.rb +90 -0
- data/lib/elkrb/layout/spore/placement.rb +57 -0
- data/lib/elkrb/layout/spore/rays.rb +119 -0
- data/lib/elkrb/layout/spore/spanning_tree.rb +53 -0
- data/lib/elkrb/layout/spore/triangulation.rb +159 -0
- data/lib/elkrb/layout_flags.rb +69 -0
- data/lib/elkrb/options/decimal.rb +50 -0
- data/lib/elkrb/options/element_options.rb +43 -0
- data/lib/elkrb/options/elk_padding.rb +20 -14
- data/lib/elkrb/options/k_vector.rb +6 -7
- data/lib/elkrb/options/k_vector_chain.rb +12 -20
- data/lib/elkrb/options/option_map.rb +85 -0
- data/lib/elkrb/options/registry.rb +335 -0
- data/lib/elkrb/options/resolver.rb +151 -0
- data/lib/elkrb/options/spellings.rb +62 -0
- data/lib/elkrb/options/unhonoured_report.rb +194 -0
- data/lib/elkrb/parsers/elkt/lexer.rb +309 -0
- data/lib/elkrb/parsers/elkt/parser.rb +424 -0
- data/lib/elkrb/parsers/elkt/resolver.rb +142 -0
- data/lib/elkrb/parsers/elkt/token.rb +40 -0
- data/lib/elkrb/parsers/elkt_parser.rb +32 -230
- data/lib/elkrb/serializers/dot_serializer.rb +342 -54
- data/lib/elkrb/serializers/elkt_serializer.rb +386 -155
- data/lib/elkrb/version.rb +1 -1
- data/lib/elkrb.rb +60 -61
- metadata +71 -49
- data/.rspec +0 -3
- data/.rubocop.yml +0 -11
- data/Gemfile +0 -13
- data/Rakefile +0 -64
- data/benchmarks/README.md +0 -172
- data/benchmarks/elkjs_benchmark.js +0 -140
- data/benchmarks/elkrb_benchmark.rb +0 -145
- data/benchmarks/fixtures/graphs.json +0 -10777
- data/benchmarks/generate_report.rb +0 -241
- data/benchmarks/generate_test_graphs.rb +0 -154
- data/benchmarks/results/elkrb_results.json +0 -280
- data/benchmarks/results/elkrb_summary.json +0 -285
- data/elkrb.gemspec +0 -39
- data/examples/dot_export_demo.rb +0 -133
- data/examples/hierarchical_graph.rb +0 -19
- data/examples/layout_constraints_demo.rb +0 -272
- data/examples/port_constraints_demo.rb +0 -291
- data/examples/self_loop_demo.rb +0 -391
- data/examples/simple_graph.rb +0 -50
- data/examples/spline_routing_demo.rb +0 -235
- data/lib/elkrb/graph/layout_options.rb +0 -247
- data/sig/elkrb/constraints.rbs +0 -114
- data/sig/elkrb/geometry.rbs +0 -61
- data/sig/elkrb/graph.rbs +0 -112
- data/sig/elkrb/layout.rbs +0 -107
- data/sig/elkrb/options.rbs +0 -81
- data/sig/elkrb.rbs +0 -32
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "lutaml/model"
|
|
4
|
-
|
|
5
|
-
module Elkrb
|
|
6
|
-
module Graph
|
|
7
|
-
class LayoutOptions < Lutaml::Model::Serializable
|
|
8
|
-
attribute :algorithm, :string
|
|
9
|
-
attribute :direction, :string
|
|
10
|
-
attribute :spacing_node_node, :float
|
|
11
|
-
attribute :spacing_edge_node, :float
|
|
12
|
-
attribute :spacing_edge_edge, :float
|
|
13
|
-
attribute :spacing_node_label, :float
|
|
14
|
-
attribute :edge_routing, :string
|
|
15
|
-
attribute :spline_curvature, :float
|
|
16
|
-
attribute :spline_segments, :integer
|
|
17
|
-
attribute :hierarchical, :boolean
|
|
18
|
-
attribute :interactive_layout, :boolean
|
|
19
|
-
attribute :aspect_ratio, :float
|
|
20
|
-
attribute :node_placement_strategy, :string
|
|
21
|
-
attribute :crossing_minimization_strategy, :string
|
|
22
|
-
attribute :layer_constraint, :string
|
|
23
|
-
attribute :cycle_breaking_strategy, :string
|
|
24
|
-
attribute :properties, :hash
|
|
25
|
-
|
|
26
|
-
json do
|
|
27
|
-
map "algorithm", to: :algorithm
|
|
28
|
-
map "direction", to: :direction
|
|
29
|
-
map "spacing.nodeNode", to: :spacing_node_node
|
|
30
|
-
map "spacing.edgeNode", to: :spacing_edge_node
|
|
31
|
-
map "spacing.edgeEdge", to: :spacing_edge_edge
|
|
32
|
-
map "spacing.nodeLabel", to: :spacing_node_label
|
|
33
|
-
map "edgeRouting", to: :edge_routing
|
|
34
|
-
map "elk.edgeRouting", to: :edge_routing
|
|
35
|
-
map "spline.curvature", to: :spline_curvature
|
|
36
|
-
map "elk.spline.curvature", to: :spline_curvature
|
|
37
|
-
map "spline.segments", to: :spline_segments
|
|
38
|
-
map "elk.spline.segments", to: :spline_segments
|
|
39
|
-
map "hierarchical", to: :hierarchical
|
|
40
|
-
map "interactiveLayout", to: :interactive_layout
|
|
41
|
-
map "aspectRatio", to: :aspect_ratio
|
|
42
|
-
map "nodePlacement.strategy", to: :node_placement_strategy
|
|
43
|
-
map "crossingMinimization.strategy",
|
|
44
|
-
to: :crossing_minimization_strategy
|
|
45
|
-
map "layerConstraint", to: :layer_constraint
|
|
46
|
-
map "cycleBreaking.strategy", to: :cycle_breaking_strategy
|
|
47
|
-
map "properties", to: :properties
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
yaml do
|
|
51
|
-
map "algorithm", to: :algorithm
|
|
52
|
-
map "direction", to: :direction
|
|
53
|
-
map "spacing_node_node", to: :spacing_node_node
|
|
54
|
-
map "spacing_edge_node", to: :spacing_edge_node
|
|
55
|
-
map "spacing_edge_edge", to: :spacing_edge_edge
|
|
56
|
-
map "spacing_node_label", to: :spacing_node_label
|
|
57
|
-
map "edge_routing", to: :edge_routing
|
|
58
|
-
map "spline_curvature", to: :spline_curvature
|
|
59
|
-
map "spline_segments", to: :spline_segments
|
|
60
|
-
map "hierarchical", to: :hierarchical
|
|
61
|
-
map "interactive_layout", to: :interactive_layout
|
|
62
|
-
map "aspect_ratio", to: :aspect_ratio
|
|
63
|
-
map "node_placement_strategy", to: :node_placement_strategy
|
|
64
|
-
map "crossing_minimization_strategy",
|
|
65
|
-
to: :crossing_minimization_strategy
|
|
66
|
-
map "layer_constraint", to: :layer_constraint
|
|
67
|
-
map "cycle_breaking_strategy", to: :cycle_breaking_strategy
|
|
68
|
-
map "properties", to: :properties
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def initialize(hash_or_attrs = {}, **attributes)
|
|
72
|
-
# Handle both hash argument and keyword arguments
|
|
73
|
-
if hash_or_attrs.is_a?(Hash) && attributes.empty?
|
|
74
|
-
# Plain hash passed as first argument
|
|
75
|
-
# Skip calling super and set defaults manually
|
|
76
|
-
@properties = hash_or_attrs.transform_keys(&:to_s)
|
|
77
|
-
@algorithm = nil
|
|
78
|
-
@direction = nil
|
|
79
|
-
@spacing_node_node = nil
|
|
80
|
-
@spacing_edge_node = nil
|
|
81
|
-
@spacing_edge_edge = nil
|
|
82
|
-
@spacing_node_label = nil
|
|
83
|
-
@edge_routing = nil
|
|
84
|
-
@spline_curvature = nil
|
|
85
|
-
@spline_segments = nil
|
|
86
|
-
@hierarchical = nil
|
|
87
|
-
@interactive_layout = nil
|
|
88
|
-
@aspect_ratio = nil
|
|
89
|
-
@node_placement_strategy = nil
|
|
90
|
-
@crossing_minimization_strategy = nil
|
|
91
|
-
@layer_constraint = nil
|
|
92
|
-
@cycle_breaking_strategy = nil
|
|
93
|
-
else
|
|
94
|
-
# Keyword arguments
|
|
95
|
-
super(**attributes)
|
|
96
|
-
@properties ||= {}
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def []=(key, value)
|
|
101
|
-
@properties[key.to_s] = value
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def [](key)
|
|
105
|
-
@properties[key.to_s]
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def merge(other_options)
|
|
109
|
-
return self unless other_options
|
|
110
|
-
|
|
111
|
-
other_options.each do |key, value|
|
|
112
|
-
self[key] = value
|
|
113
|
-
end
|
|
114
|
-
self
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Port constraint options
|
|
118
|
-
|
|
119
|
-
# Get port constraints setting
|
|
120
|
-
#
|
|
121
|
-
# Port constraint values:
|
|
122
|
-
# - "UNDEFINED" - No constraints (default)
|
|
123
|
-
# - "FIXED_SIDE" - Port sides are fixed
|
|
124
|
-
# - "FIXED_ORDER" - Port sides and order are fixed
|
|
125
|
-
# - "FIXED_POS" - Port positions are completely fixed
|
|
126
|
-
#
|
|
127
|
-
# @return [String] The port constraints setting
|
|
128
|
-
def port_constraints
|
|
129
|
-
properties["elk.portConstraints"] ||
|
|
130
|
-
properties["portConstraints"] ||
|
|
131
|
-
"UNDEFINED"
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
# Set port constraints
|
|
135
|
-
#
|
|
136
|
-
# @param value [String] The port constraints value
|
|
137
|
-
def port_constraints=(value)
|
|
138
|
-
properties["elk.portConstraints"] = value
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Get port side assignment setting
|
|
142
|
-
#
|
|
143
|
-
# Port side assignment values:
|
|
144
|
-
# - "AUTOMATIC" - Auto-detect from position (default)
|
|
145
|
-
# - "MANUAL" - Use explicitly specified sides
|
|
146
|
-
#
|
|
147
|
-
# @return [String] The port side assignment setting
|
|
148
|
-
def port_side_assignment
|
|
149
|
-
properties["elk.portSideAssignment"] ||
|
|
150
|
-
properties["portSideAssignment"] ||
|
|
151
|
-
"AUTOMATIC"
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
# Set port side assignment
|
|
155
|
-
#
|
|
156
|
-
# @param value [String] The port side assignment value
|
|
157
|
-
def port_side_assignment=(value)
|
|
158
|
-
properties["elk.portSideAssignment"] = value
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
# Get port ordering setting
|
|
162
|
-
#
|
|
163
|
-
# Port ordering values:
|
|
164
|
-
# - "DEFAULT" - Algorithm-specific default
|
|
165
|
-
# - "INDEX" - Use port index attribute
|
|
166
|
-
# - "OFFSET" - Use port offset/position
|
|
167
|
-
#
|
|
168
|
-
# @return [String] The port ordering setting
|
|
169
|
-
def port_ordering
|
|
170
|
-
properties["elk.portOrdering"] ||
|
|
171
|
-
properties["portOrdering"] ||
|
|
172
|
-
"DEFAULT"
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
# Set port ordering
|
|
176
|
-
#
|
|
177
|
-
# @param value [String] The port ordering value
|
|
178
|
-
def port_ordering=(value)
|
|
179
|
-
properties["elk.portOrdering"] = value
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
# Self-loop options
|
|
183
|
-
|
|
184
|
-
# Get self-loop side setting
|
|
185
|
-
#
|
|
186
|
-
# Self-loop side values:
|
|
187
|
-
# - "EAST" - Loop extends to the right (default)
|
|
188
|
-
# - "WEST" - Loop extends to the left
|
|
189
|
-
# - "NORTH" - Loop extends upward
|
|
190
|
-
# - "SOUTH" - Loop extends downward
|
|
191
|
-
#
|
|
192
|
-
# @return [String] The self-loop side setting
|
|
193
|
-
def self_loop_side
|
|
194
|
-
properties["elk.selfLoopSide"] ||
|
|
195
|
-
properties["selfLoopSide"] ||
|
|
196
|
-
"EAST"
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
# Set self-loop side
|
|
200
|
-
#
|
|
201
|
-
# @param value [String] The self-loop side value
|
|
202
|
-
def self_loop_side=(value)
|
|
203
|
-
properties["elk.selfLoopSide"] = value
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
# Get self-loop offset setting
|
|
207
|
-
#
|
|
208
|
-
# Controls the base distance the self-loop extends from the node.
|
|
209
|
-
# Multiple self-loops on the same node will use increasing offsets.
|
|
210
|
-
#
|
|
211
|
-
# @return [Float] The self-loop offset (default: 20.0)
|
|
212
|
-
def self_loop_offset
|
|
213
|
-
(properties["elk.selfLoopOffset"] ||
|
|
214
|
-
properties["selfLoopOffset"] ||
|
|
215
|
-
20.0).to_f
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# Set self-loop offset
|
|
219
|
-
#
|
|
220
|
-
# @param value [Float] The self-loop offset value
|
|
221
|
-
def self_loop_offset=(value)
|
|
222
|
-
properties["elk.selfLoopOffset"] = value
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
# Get self-loop routing style
|
|
226
|
-
#
|
|
227
|
-
# Self-loop routing values:
|
|
228
|
-
# - "ORTHOGONAL" - Rectangular path with 90-degree corners (default)
|
|
229
|
-
# - "SPLINES" - Smooth curved path using Bezier curves
|
|
230
|
-
# - "POLYLINE" - Simple polyline path
|
|
231
|
-
#
|
|
232
|
-
# @return [String] The self-loop routing style
|
|
233
|
-
def self_loop_routing
|
|
234
|
-
properties["elk.selfLoopRouting"] ||
|
|
235
|
-
properties["selfLoopRouting"] ||
|
|
236
|
-
"ORTHOGONAL"
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
# Set self-loop routing style
|
|
240
|
-
#
|
|
241
|
-
# @param value [String] The self-loop routing style value
|
|
242
|
-
def self_loop_routing=(value)
|
|
243
|
-
properties["elk.selfLoopRouting"] = value
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
end
|
data/sig/elkrb/constraints.rbs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Type signatures for ElkRb layout constraints
|
|
2
|
-
|
|
3
|
-
module Elkrb
|
|
4
|
-
module Graph
|
|
5
|
-
# Relative offset for positioning
|
|
6
|
-
class RelativeOffset < Lutaml::Model::Serializable
|
|
7
|
-
attr_accessor x: Float
|
|
8
|
-
attr_accessor y: Float
|
|
9
|
-
|
|
10
|
-
def initialize: (?x: Float, ?y: Float) -> void
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Node positioning constraints
|
|
14
|
-
class NodeConstraints < Lutaml::Model::Serializable
|
|
15
|
-
attr_accessor fixed_position: bool
|
|
16
|
-
attr_accessor layer: Integer?
|
|
17
|
-
attr_accessor align_group: String?
|
|
18
|
-
attr_accessor align_direction: String?
|
|
19
|
-
attr_accessor relative_to: String?
|
|
20
|
-
attr_accessor relative_offset: RelativeOffset?
|
|
21
|
-
attr_accessor position_priority: Integer
|
|
22
|
-
|
|
23
|
-
HORIZONTAL: String
|
|
24
|
-
VERTICAL: String
|
|
25
|
-
ALIGN_DIRECTIONS: Array[String]
|
|
26
|
-
|
|
27
|
-
def initialize: (
|
|
28
|
-
?fixed_position: bool,
|
|
29
|
-
?layer: Integer?,
|
|
30
|
-
?align_group: String?,
|
|
31
|
-
?align_direction: String?,
|
|
32
|
-
?relative_to: String?,
|
|
33
|
-
?relative_offset: RelativeOffset?,
|
|
34
|
-
?position_priority: Integer
|
|
35
|
-
) -> void
|
|
36
|
-
|
|
37
|
-
def align_direction=: (String? value) -> String?
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
module Layout
|
|
42
|
-
module Constraints
|
|
43
|
-
# Base constraint class
|
|
44
|
-
class BaseConstraint
|
|
45
|
-
def apply: (Graph::Graph graph) -> Graph::Graph
|
|
46
|
-
def validate: (Graph::Graph graph) -> Array[String]
|
|
47
|
-
def applies_to?: (Graph::Node node) -> bool
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def find_node: (Graph::Graph graph, String node_id) -> Graph::Node?
|
|
52
|
-
def all_nodes: (Graph::Graph graph) -> Array[Graph::Node]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Fixed position constraint
|
|
56
|
-
class FixedPositionConstraint < BaseConstraint
|
|
57
|
-
def apply: (Graph::Graph graph) -> Graph::Graph
|
|
58
|
-
def validate: (Graph::Graph graph) -> Array[String]
|
|
59
|
-
def restore_fixed_positions: (Graph::Graph graph) -> Graph::Graph
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Alignment constraint
|
|
63
|
-
class AlignmentConstraint < BaseConstraint
|
|
64
|
-
def apply: (Graph::Graph graph) -> Graph::Graph
|
|
65
|
-
def validate: (Graph::Graph graph) -> Array[String]
|
|
66
|
-
|
|
67
|
-
private
|
|
68
|
-
|
|
69
|
-
def group_by_alignment: (Array[Graph::Node] nodes) -> Hash[[String, String], Array[Graph::Node]]
|
|
70
|
-
def align_nodes: (Array[Graph::Node] nodes, String direction) -> void
|
|
71
|
-
def align_horizontally: (Array[Graph::Node] nodes) -> void
|
|
72
|
-
def align_vertically: (Array[Graph::Node] nodes) -> void
|
|
73
|
-
def validate_group_alignment: (Array[Graph::Node] nodes, String group_name, String direction) -> Array[String]
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Layer constraint
|
|
77
|
-
class LayerConstraint < BaseConstraint
|
|
78
|
-
def apply: (Graph::Graph graph) -> Graph::Graph
|
|
79
|
-
def validate: (Graph::Graph graph) -> Array[String]
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Relative position constraint
|
|
83
|
-
class RelativePositionConstraint < BaseConstraint
|
|
84
|
-
def apply: (Graph::Graph graph) -> Graph::Graph
|
|
85
|
-
def validate: (Graph::Graph graph) -> Array[String]
|
|
86
|
-
|
|
87
|
-
private
|
|
88
|
-
|
|
89
|
-
def apply_relative_position: (Graph::Node node, Graph::Graph graph) -> void
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Constraint processor
|
|
93
|
-
class ConstraintProcessor
|
|
94
|
-
PRE_LAYOUT_CONSTRAINTS: Array[singleton(BaseConstraint)]
|
|
95
|
-
POST_LAYOUT_CONSTRAINTS: Array[singleton(BaseConstraint)]
|
|
96
|
-
|
|
97
|
-
@pre_constraints: Array[BaseConstraint]
|
|
98
|
-
@post_constraints: Array[BaseConstraint]
|
|
99
|
-
@all_constraints: Array[BaseConstraint]
|
|
100
|
-
|
|
101
|
-
def initialize: () -> void
|
|
102
|
-
def apply_pre_layout: (Graph::Graph graph) -> Graph::Graph
|
|
103
|
-
def enforce_post_layout: (Graph::Graph graph) -> Graph::Graph
|
|
104
|
-
def apply_all: (Graph::Graph graph) -> Graph::Graph
|
|
105
|
-
def validate_all: (Graph::Graph graph) -> Array[String]
|
|
106
|
-
def has_constraints?: (Graph::Graph graph) -> bool
|
|
107
|
-
|
|
108
|
-
private
|
|
109
|
-
|
|
110
|
-
def has_constraints_recursive?: (Graph::Node node) -> bool
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
data/sig/elkrb/geometry.rbs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module Elkrb
|
|
2
|
-
module Geometry
|
|
3
|
-
class Point
|
|
4
|
-
attr_reader x: Float
|
|
5
|
-
attr_reader y: Float
|
|
6
|
-
|
|
7
|
-
def initialize: (Float x, Float y) -> void
|
|
8
|
-
def +: (Point other) -> Point
|
|
9
|
-
def -: (Point other) -> Point
|
|
10
|
-
def *: (Float scalar) -> Point
|
|
11
|
-
def /: (Float scalar) -> Point
|
|
12
|
-
def distance_to: (Point other) -> Float
|
|
13
|
-
def ==: (untyped other) -> bool
|
|
14
|
-
def to_h: () -> Hash[Symbol, Float]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class Dimension
|
|
18
|
-
attr_reader width: Float
|
|
19
|
-
attr_reader height: Float
|
|
20
|
-
|
|
21
|
-
def initialize: (Float width, Float height) -> void
|
|
22
|
-
def area: () -> Float
|
|
23
|
-
def ==: (untyped other) -> bool
|
|
24
|
-
def to_h: () -> Hash[Symbol, Float]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class Rectangle
|
|
28
|
-
attr_reader x: Float
|
|
29
|
-
attr_reader y: Float
|
|
30
|
-
attr_reader width: Float
|
|
31
|
-
attr_reader height: Float
|
|
32
|
-
|
|
33
|
-
def initialize: (Float x, Float y, Float width, Float height) -> void
|
|
34
|
-
def left: () -> Float
|
|
35
|
-
def right: () -> Float
|
|
36
|
-
def top: () -> Float
|
|
37
|
-
def bottom: () -> Float
|
|
38
|
-
def center: () -> Point
|
|
39
|
-
def contains?: (Point | Rectangle point_or_rect) -> bool
|
|
40
|
-
def intersects?: (Rectangle other) -> bool
|
|
41
|
-
def ==: (untyped other) -> bool
|
|
42
|
-
def to_h: () -> Hash[Symbol, Float]
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
class Vector
|
|
46
|
-
attr_reader x: Float
|
|
47
|
-
attr_reader y: Float
|
|
48
|
-
|
|
49
|
-
def initialize: (Float x, Float y) -> void
|
|
50
|
-
def +: (Vector other) -> Vector
|
|
51
|
-
def -: (Vector other) -> Vector
|
|
52
|
-
def *: (Float scalar) -> Vector
|
|
53
|
-
def /: (Float scalar) -> Vector
|
|
54
|
-
def magnitude: () -> Float
|
|
55
|
-
def normalize: () -> Vector
|
|
56
|
-
def dot: (Vector other) -> Float
|
|
57
|
-
def ==: (untyped other) -> bool
|
|
58
|
-
def to_h: () -> Hash[Symbol, Float]
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
data/sig/elkrb/graph.rbs
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
module Elkrb
|
|
2
|
-
module Graph
|
|
3
|
-
class LayoutOptions
|
|
4
|
-
attr_accessor algorithm: String?
|
|
5
|
-
attr_accessor direction: String?
|
|
6
|
-
attr_accessor spacing_node_node: Float?
|
|
7
|
-
attr_accessor spacing_edge_node: Float?
|
|
8
|
-
attr_accessor spacing_edge_edge: Float?
|
|
9
|
-
attr_accessor edge_routing: String?
|
|
10
|
-
attr_accessor padding: Hash[Symbol, Float]?
|
|
11
|
-
attr_accessor aspect_ratio: Float?
|
|
12
|
-
|
|
13
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> LayoutOptions
|
|
14
|
-
def to_json: () -> String
|
|
15
|
-
def to_yaml: () -> String
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
class Label
|
|
19
|
-
attr_accessor id: String?
|
|
20
|
-
attr_accessor text: String?
|
|
21
|
-
attr_accessor x: Float?
|
|
22
|
-
attr_accessor y: Float?
|
|
23
|
-
attr_accessor width: Float?
|
|
24
|
-
attr_accessor height: Float?
|
|
25
|
-
|
|
26
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Label
|
|
27
|
-
def to_json: () -> String
|
|
28
|
-
def to_yaml: () -> String
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class Port
|
|
32
|
-
attr_accessor id: String?
|
|
33
|
-
attr_accessor x: Float?
|
|
34
|
-
attr_accessor y: Float?
|
|
35
|
-
attr_accessor width: Float?
|
|
36
|
-
attr_accessor height: Float?
|
|
37
|
-
attr_accessor labels: Array[Label]?
|
|
38
|
-
|
|
39
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Port
|
|
40
|
-
def to_json: () -> String
|
|
41
|
-
def to_yaml: () -> String
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
class EdgeSection
|
|
45
|
-
attr_accessor id: String?
|
|
46
|
-
attr_accessor start_point: Hash[String, Float]?
|
|
47
|
-
attr_accessor end_point: Hash[String, Float]?
|
|
48
|
-
attr_accessor bend_points: Array[Hash[String, Float]]?
|
|
49
|
-
attr_accessor incoming_shape: String?
|
|
50
|
-
attr_accessor outgoing_shape: String?
|
|
51
|
-
|
|
52
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> EdgeSection
|
|
53
|
-
def to_json: () -> String
|
|
54
|
-
def to_yaml: () -> String
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
class Edge
|
|
58
|
-
attr_accessor id: String?
|
|
59
|
-
attr_accessor sources: Array[String]?
|
|
60
|
-
attr_accessor targets: Array[String]?
|
|
61
|
-
attr_accessor labels: Array[Label]?
|
|
62
|
-
attr_accessor sections: Array[EdgeSection]?
|
|
63
|
-
attr_accessor layout_options: LayoutOptions?
|
|
64
|
-
attr_accessor properties: Hash[String, untyped]?
|
|
65
|
-
|
|
66
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Edge
|
|
67
|
-
def to_json: () -> String
|
|
68
|
-
def to_yaml: () -> String
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
class Node
|
|
72
|
-
attr_accessor id: String?
|
|
73
|
-
attr_accessor x: Float?
|
|
74
|
-
attr_accessor y: Float?
|
|
75
|
-
attr_accessor width: Float?
|
|
76
|
-
attr_accessor height: Float?
|
|
77
|
-
attr_accessor labels: Array[Label]?
|
|
78
|
-
attr_accessor ports: Array[Port]?
|
|
79
|
-
attr_accessor children: Array[Node]?
|
|
80
|
-
attr_accessor edges: Array[Edge]?
|
|
81
|
-
attr_accessor layout_options: LayoutOptions?
|
|
82
|
-
attr_accessor properties: Hash[String, untyped]?
|
|
83
|
-
|
|
84
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Node
|
|
85
|
-
def to_json: () -> String
|
|
86
|
-
def to_yaml: () -> String
|
|
87
|
-
def hierarchical?: () -> bool
|
|
88
|
-
def find_node: (String node_id) -> Node?
|
|
89
|
-
def all_nodes: () -> Array[Node]
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
class Graph
|
|
93
|
-
attr_accessor id: String?
|
|
94
|
-
attr_accessor x: Float?
|
|
95
|
-
attr_accessor y: Float?
|
|
96
|
-
attr_accessor width: Float?
|
|
97
|
-
attr_accessor height: Float?
|
|
98
|
-
attr_accessor children: Array[Node]?
|
|
99
|
-
attr_accessor edges: Array[Edge]?
|
|
100
|
-
attr_accessor layout_options: LayoutOptions?
|
|
101
|
-
attr_accessor properties: Hash[String, untyped]?
|
|
102
|
-
|
|
103
|
-
def self.from_hash: (Hash[String | Symbol, untyped] hash) -> Graph
|
|
104
|
-
def to_json: () -> String
|
|
105
|
-
def to_yaml: () -> String
|
|
106
|
-
def hierarchical?: () -> bool
|
|
107
|
-
def find_node: (String node_id) -> Node?
|
|
108
|
-
def all_nodes: () -> Array[Node]
|
|
109
|
-
def all_edges: () -> Array[Edge]
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
end
|
data/sig/elkrb/layout.rbs
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
module Elkrb
|
|
2
|
-
module Layout
|
|
3
|
-
type algorithmMetadata = {
|
|
4
|
-
name: String,
|
|
5
|
-
description: String,
|
|
6
|
-
category: String?,
|
|
7
|
-
supports_hierarchy: bool?
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type algorithmInfo = {
|
|
11
|
-
id: String,
|
|
12
|
-
name: String,
|
|
13
|
-
description: String,
|
|
14
|
-
category: String,
|
|
15
|
-
supports_hierarchy: bool
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class AlgorithmRegistry
|
|
19
|
-
def self.register: (String name, singleton(Algorithms::BaseAlgorithm) algorithm_class, ?algorithmMetadata metadata) -> void
|
|
20
|
-
def self.get: (String name) -> singleton(Algorithms::BaseAlgorithm)?
|
|
21
|
-
def self.available_algorithms: () -> Array[String]
|
|
22
|
-
def self.algorithm_info: (String name) -> algorithmInfo?
|
|
23
|
-
def self.all_algorithm_info: () -> Array[algorithmInfo]
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
def self.normalize_name: (String name) -> String
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
class LayoutEngine
|
|
31
|
-
def self.layout: (Hash[String | Symbol, untyped] | Graph::Graph graph, Hash[String | Symbol, untyped] options) -> Graph::Graph
|
|
32
|
-
def self.known_layout_algorithms: () -> Array[algorithmInfo]
|
|
33
|
-
def self.known_layout_options: () -> Array[untyped]
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
|
|
37
|
-
def self.convert_to_graph: (Hash[String | Symbol, untyped] hash) -> Graph::Graph
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
module Algorithms
|
|
41
|
-
class BaseAlgorithm
|
|
42
|
-
attr_reader options: Hash[String | Symbol, untyped]
|
|
43
|
-
|
|
44
|
-
def initialize: (Hash[String | Symbol, untyped] options) -> void
|
|
45
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def option: (String | Symbol key, ?untyped default) -> untyped
|
|
50
|
-
def node_spacing: () -> Float
|
|
51
|
-
def padding: () -> Hash[Symbol, Float]
|
|
52
|
-
def calculate_bounding_box: (Array[Graph::Node] nodes) -> Geometry::Rectangle
|
|
53
|
-
def apply_padding: (Graph::Graph graph) -> void
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
class Random < BaseAlgorithm
|
|
57
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
class Fixed < BaseAlgorithm
|
|
61
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
class Box < BaseAlgorithm
|
|
65
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
class Force < BaseAlgorithm
|
|
69
|
-
DEFAULT_ITERATIONS: Integer
|
|
70
|
-
DEFAULT_REPULSION: Float
|
|
71
|
-
DEFAULT_TEMPERATURE: Float
|
|
72
|
-
|
|
73
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
74
|
-
|
|
75
|
-
private
|
|
76
|
-
|
|
77
|
-
def iterations: () -> Integer
|
|
78
|
-
def repulsion: () -> Float
|
|
79
|
-
def temperature: () -> Float
|
|
80
|
-
def collect_edges: (Graph::Graph graph) -> Array[Graph::Edge]
|
|
81
|
-
def initialize_positions: (Graph::Graph graph) -> void
|
|
82
|
-
def apply_forces: (Graph::Graph graph, Float repulsion, Float temperature, Integer iteration, Integer total_iterations) -> void
|
|
83
|
-
def calculate_repulsive_forces: (Array[Graph::Node] nodes, Float repulsion) -> Hash[String, Geometry::Vector]
|
|
84
|
-
def calculate_attractive_forces: (Array[Graph::Edge] edges, Float temperature) -> Hash[String, Geometry::Vector]
|
|
85
|
-
def apply_displacement: (Array[Graph::Node] nodes, Hash[String, Geometry::Vector] forces, Float cooling_factor) -> void
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
class Stress < BaseAlgorithm
|
|
89
|
-
DEFAULT_ITERATIONS: Integer
|
|
90
|
-
DEFAULT_EPSILON: Float
|
|
91
|
-
|
|
92
|
-
def layout: (Graph::Graph graph) -> Graph::Graph
|
|
93
|
-
|
|
94
|
-
private
|
|
95
|
-
|
|
96
|
-
def iterations: () -> Integer
|
|
97
|
-
def epsilon: () -> Float
|
|
98
|
-
def collect_edges: (Graph::Graph graph) -> Array[Graph::Edge]
|
|
99
|
-
def initialize_positions: (Graph::Graph graph) -> void
|
|
100
|
-
def calculate_distances: (Graph::Graph graph) -> Hash[String, Hash[String, Float]]
|
|
101
|
-
def calculate_stress: (Graph::Graph graph, Hash[String, Hash[String, Float]] distances) -> Float
|
|
102
|
-
def optimize_positions: (Graph::Graph graph, Hash[String, Hash[String, Float]] distances) -> void
|
|
103
|
-
def euclidean_distance: (Graph::Node n1, Graph::Node n2) -> Float
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|