You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Graphviz保持rankdir=LR时自定义节点端口边对齐方式问询

调整后完整代码

graph g{
    rankdir = "LR";
    splines=false; 

    "tab1" [
        label = <<table border="1" cellspacing="1" bgcolor="deepskyblue">
            <tr><td colspan="75" port="f0" border="1" bgcolor="gray">header</td></tr>
            <tr><td colspan="75" port="f1" border="1" width="20" bgcolor="deepskyblue">row1</td></tr>  
            <tr><td colspan="75" port="f2" border="1" bgcolor="gold">row2</td></tr>
        </table>>
        shape = "none"
        width ="2"
        group="udm";
    ];

    tab1:f1:e -- tab1:f2:e [color=blue,style=solid penwidth=1.5,constraint=false];
}

核心修改说明

  • 修正了原代码中无效的shape = "yes"配置,替换为shape = "none",避免节点默认边框和自定义HTML表格样式冲突
  • 连线端点增加:e后缀,指定连接两个行端口的东侧位置,让连线起点、终点都落在表格右侧外部
  • 给连线新增constraint=false属性,避免连线逻辑干扰节点原有布局排序,保留表格行的纵向排列效果,不受rankdir=LR配置影响

内容的提问来源于stack exchange,提问作者Ashish

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 04:48:02