TALA is open-sourceTALA 是开源的
Following up on the announcement here, TALA (Terrastruct's AutoLayout Algorithm) is now open-source under the same license as D2 (MPL-2.0).继此处公告之后,TALA(Terrastruct 的 AutoLayout 算法)现已开源,采用与 D2 相同的许可证(MPL-2.0)。
TALA is a novel autolayout algorithm designed with software architecture diagrams in mind. This means it's primarily an orthogonal layout engine, which more closely matches what you might find on whiteboards, rather than the DAG-based ones that grow in one direction. It blends ideas from different graph-drawing research papers (cited in source code) along with original techniques to achieve aesthetic diagrams. It considers multiple objectives of "aesthetic", including symmetry, median distance, flow, clustering of like nodes, and much more.TALA 是一种新颖的自动布局算法,专为软件架构图而设计。这意味着它主要是一个正交布局引擎,更接近于你在白板上可能看到的内容,而不是那种朝一个方向生长的基于 DAG 的布局。它融合了来自不同图绘制研究论文(在源码中引用)的思想以及原创技术,以实现美观的图表。它考虑了“美观”的多个目标,包括对称性、中位距离、流向、相似节点的聚类等等。
I'll keep the text short and lead with examples.我会保持文字简短,并以示例开头。
- The first batch compares diagrams rendered with TALA with the other two layout algorithms D2 comes with -- Dagre and ELK. These are not hand-selected, I just found public d2 files from around GitHub. So for some, you may very well prefer the not-TALA layout.第一批比较了使用 TALA 渲染的图表与 D2 附带的另外两种布局算法——Dagre 和 ELK——渲染的图表。这些并非手工挑选,我只是从 GitHub 上找到了公开的 d2 文件。因此,对于某些图表,你很可能更喜欢非 TALA 的布局。
- The second batch demonstrates a unique property of TALA, which is that node positions and sizes can be customized, e.g. locking in the coordinates. This lends itself especially well to agentic use cases, where models can draw in 2D space well, but TALA still takes care of routing, which models still struggle with. I had AI generate these.第二批展示了 TALA 的一个独特属性,即节点位置和大小可以自定义,例如锁定坐标。这特别适合智能体用例,模型可以很好地绘制 2D 空间,但 TALA 仍然负责处理模型仍难以应对的路由。这些是我让 AI 生成的。
- The third batch demonstrates TALA's capability to support a hybrid of some nodes specifying coordinates and some left to the layout engine. You might have a specific shape of a collection of nodes in mind, which you can specify with coordinates, and TALA can take care of the rest. Again, AI generated.第三批展示了 TALA 支持混合模式的能力,即一些节点指定坐标,另一些留给布局引擎。你可能对一组节点的特定形状有想法,可以用坐标指定,TALA 可以处理其余部分。同样是 AI 生成的。
Please also note that TALA is not without tradeoffs.另请注意,TALA 并非没有取舍。
- It has randomness in the algorithm. It finds the best layout by using a default of 3 seeds and choosing the one scored the best. Given the same seeds and same input, it'll produce the same diagram. But let's say you just add one more node. The diagram could look completely different. In Dagre and ELK, it looks mostly the same as prior, with the extra node accommodated for. This is sometimes desirable.它的算法具有随机性。它通过默认使用 3 个种子并选择评分最高的一个来找到最佳布局。给定相同的种子和相同的输入,它将生成相同的图表。但假设你只增加一个节点,图表可能会看起来完全不同。而在 Dagre 和 ELK 中,它看起来与之前大致相同,只是容纳了额外的节点。这有时是可取的。
- It doesn't do DAGs as well. I often find myself preferring Dagre or ELK when I want a long flowing graph.它处理 DAG 的效果没那么好。当我想要一个长而流畅的图时,我经常发现自己更喜欢 Dagre 或 ELK。
- It can take longer to run for larger diagrams -- scaling nonlinearly. For a benchmark of TALA's runtime performance compared to others, see https://github.com/d2lang/d2-benchmarks.对于较大的图表,运行时间可能更长——呈非线性扩展。有关 TALA 与其他布局算法运行时性能对比的基准测试,请参阅 https://github.com/d2lang/d2-benchmarks。
TALA comes bundled into D2 v0.9.0, so just install and specify with --layout=tala to try it out! Or head on over to https://play.d2lang.com, which runs 100% client-side. I especially look forward to the improvements that being open-source brings, and can't wait to see what improvements and ideas are submitted by the community.TALA 已捆绑到 D2 v0.9.0 中,因此只需安装并使用 --layout=tala 指定即可试用!或者前往 https://play.d2lang.com,它 100% 在客户端运行。我尤其期待开源带来的改进,迫不及待想看到社区提交的改进和想法。
Special thanks to Gavin Nishizawa for substantial broad contributions across TALA, and Júlio César Batista for his work on hierarchy algorithms and more. It was so fun getting to work on such interesting stuff with you guys.特别感谢 Gavin Nishizawa 对 TALA 做出的广泛而重大的贡献,以及 Júlio César Batista 在层次算法等方面的工作。能和大家一起研究这么有趣的东西真是太有意思了。
Batch 1: Comparisons第一批:比较
Fulcro RAD architectureFulcro RAD 架构
Select a diagram to enlarge it. Each layout is scaled to fit its panel.选择图表以放大。每种布局都会缩放以适应其面板。
Mocha secure-enclave SoCMocha 安全隔区 SoC
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
Jupyter on AWS EKSAWS EKS 上的 Jupyter
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
Lion Reader frontend data flowLion Reader 前端数据流
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
ROSS rotor-dynamics workflowROSS 旋翼动力学工作流
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
Go Queue worker architectureGo Queue 工作器架构
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
Ouroboros Leios simulatorOuroboros Leios 模拟器
Select a diagram to enlarge it. Each layout is scaled to fit its panel.
Batch 2: Custom positioning第二批:自定义定位
Signal HouseSignal House
View D2 source查看 D2 源码
Atlas / Data platformAtlas / 数据平台
View D2 source
Night shift / Mission control夜班 / 任务控制
View D2 source
Friday deploy: the escape room周五部署:逃生室
View D2 source
The Internet is a jellyfish互联网是一只水母
View D2 source
Orbital coffee logistics轨道咖啡物流
View D2 source
Cloud Conservatory云温室
View D2 source
Velvet Rope天鹅绒绳
View D2 source
Synthwave City合成器浪潮城市
View D2 source
Batch 3: Partial positioning第三批:部分定位
The Printing Room印刷室
Pinned: The four CMYK stations share a fixed top coordinate and equally spaced left coordinates so the print sequence retains its mechanical alignment.固定:四个 CMYK 工作站共享固定的 top 坐标和等间距的 left 坐标,以便印刷序列保持其机械对齐。
Automatic: TALA positions the feeder, camera, registration controller, dryer, prepress and finishing steps; none has top or left.自动:TALA 定位进纸器、相机、套准控制器、干燥器、印前和印后步骤;它们都没有指定 top 或 left。
See the positioning declarations查看定位声明
View D2 source
MULE / Utility RoverMULE / 多用途漫游车
Pinned: The four motor assemblies are fixed at the front and rear corners of the chassis rectangle.固定:四个电机组件固定在底盘矩形的前后角。
Automatic: TALA places every controller, sensor, power and safety node between or around those corners and arranges the unpositioned fleet container.自动:TALA 将每个控制器、传感器、电源和安全节点放置在这些角之间或周围,并安排未定位的车队容器。
See the positioning declarations
View D2 source
Sources and rendering details来源和渲染细节
The seven layout comparisons use public project diagrams from D2's real-world fixtures. Each comparison uses the same D2 source and the same compiler build, changing only the layout engine. Source styles, themes, and explicit grid constraints are preserved. Some fixture icons were already replaced with built-in shapes.七个布局比较使用了 D2 真实世界测试夹具中的公共项目图表。 每个比较使用相同的 D2 源码和相同的编译器构建,仅更改布局引擎。源样式、主题和显式网格约束均被保留。一些测试夹具图标已被内置形状替换。
SVGs are scaled independently to fit each panel. Use Open SVG to inspect labels and connections at a larger size.SVG 被独立缩放以适应每个面板。使用“打开 SVG”以更大的尺寸检查标签和连接。
Source provenance and licenses ·源码来源和许可证 ·
Render settings and revisions
渲染设置和修订The eleven positioning examples are original, fictional compositions rendered with TALA using the same public D2 build. Icon downloads include the full source and local vector assets. The two partial-positioning examples apply top/left only to their listed pinned nodes; all other nodes and every container are automatically placed.十一个定位示例是原创的虚构构图,使用相同的公共 D2 构建和 TALA 渲染。图标下载包括完整源码和本地矢量资源。两个部分定位示例仅将 top/left 应用于列出的固定节点;所有其他节点和每个容器均自动放置。
Positioning render settings
定位渲染设置.