精简的点语言=真混淆了图表

时间:2015-05-15 13:08:17

标签: graph graphviz dot

我画了一个如下图所示的简单图形,发现了彩色显示的不同行为。

digraph G {
     concentrate=true
    edge [dir=none]
     a  -> b [color=red]
     b -> c   
     c -> b 
     b -> a 
    }

Correct Image of graph

图表显示a和b之间的边缘是红色>>这个是正确的。

但是当我把它改成

     digraph G {
     concentrate=true
    edge [dir=none]
     a  -> b 
     b -> c   
     c -> b 
     b -> a [color=red]
    }

Red color not show

这次边缘a和b的颜色是黑色而不是我想要的红色。 有人能弄清楚我在这里做错了吗?

2 个答案:

答案 0 :(得分:0)

分析

因为问题中的代码在另一个上面绘制了两条边,所以绘制的最后一条边的颜色获胜。 Dot的布局引擎可以从底部到顶部或从右到左工作。这意味着绘制的最后一个边是第一个列出的边。

一般解决方案

Dot绘制有向图。可以使用dir=none模拟无向图,但是应该只有一条边:

digraph G {
  concentrate=true
  edge [dir=none]
  a -> b [color=red]
  b -> c
 }

digraph showing sue of dir=none property

替代

请注意,dir=none并非主要用作展示属性。如果目标是两个有向边,那么dir=both是更好的选择:

digraph G {
  concentrate=true
  edge [dir=both]
  a -> b [color="red:black"]
  b -> c [color="black:black]
}

digraph showing use of dir=both attribute

备注

从概念上将图形与显示属性建模分开是很有用的。 Dot并没有使这一点特别容易,因为它鼓励内联样式信息。但分离问题的代价可能会在调试时间上得到回报。

答案 1 :(得分:0)

您可以使用端口来防止边缘重叠:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\..+$
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) https://example.com/$1/ [R=301,L]

result

另请参阅:https://graphviz.gitlab.io/_pages/doc/info/lang.html