TALA Is Open-Source
TALA Is Open-Source
TALA 正式开源
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 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.
继此前的公告之后,TALA (Terrastruct 自动布局算法) 现已正式开源,采用与 D2 相同的许可证 (MPL-2.0)。TALA 是一种专为软件架构图设计的新型自动布局算法。这意味着它主要是一个正交布局引擎,相比于那些单向增长的 DAG(有向无环图)布局,它更接近于我们在白板上绘制图表的方式。
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. 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 的一个独特属性:节点的位置和大小可以自定义,例如锁定坐标。这特别适用于智能体(Agentic)应用场景——模型可以很好地在二维空间中进行绘图,而 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. 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.
请注意,TALA 并非没有权衡。该算法具有随机性。它默认使用 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. 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.
它在处理 DAG(有向无环图)方面表现不如其他算法。当我需要长流向的图表时,我通常更倾向于使用 Dagre 或 ELK。对于较大的图表,它的运行时间可能会更长——呈现非线性扩展。有关 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,该网站完全在客户端运行。我特别期待开源带来的改进,也迫不及待地想看到社区提交的优化建议和新想法。
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 在层次算法等方面的工作。能与你们一起从事如此有趣的项目,我感到非常愉快。