graph-theory - 用图点连接边

标签 graph-theory graphviz dot

我需要使用点在两条边之间添加链接。 我需要添加到图表中的是图中显示的两个边缘之间标记为“b”的红色链接。

源代码如下:

digraph { 
    a -> b; 
    a -> c; 
} 

enter image description here

最佳答案

今天我遇到了同样的问题,并通过一个小技巧解决了它:

  1. 为要连接的每条边创建小点状节点
  2. 通过假节点连接主节点
  3. 连接假节点
digraph {
    fakeAB [label="", shape=point, width=0.01, height=0.01];
    fakeAC [label="", shape=point, width=0.01, height=0.01];

    {
        rank=same;
            "b"; "c";
    }

    {
        rank=same;
            fakeAB; fakeAC;
    }

    "a" -> fakeAB [arrowhead=none];
    "a" -> fakeAC [arrowhead=none];
    fakeAB -> "b";
    fakeAC -> "c";

    fakeAB -> fakeAC [label="b", color="red", arrowhead=none];
}

结果:

Connected Edges

关于graph-theory - 用图点连接边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26845540/

相关文章:

Graphviz - 什么是有效的样式属性?

算法 : Using maximum flow to calculate correct matrix values

python - 为什么 networkx 每次运行重绘我的图形都不一样?

python - 在 Python 中查找图的树分解

graphviz - 对 Graphviz 实体关系图中的表名称进行着色

graphviz: "same"周围的虚线框 - 分组框

java - 在 JGraphT SimpleGraph 中使用相等的顶点

fedora - Dot 不支持新安装的 Graphviz 中的任何格式

graphviz - 如何调整点图中边缘的方向?

graphviz - dot/Graphviz 更紧凑的层次布局