2013-07-15 58 views

回答

1

您是否需要某些需要点文件并生成新的彩色点文件?或者你有一些程序或脚本产生你的点文件? (使用什么语言?)

我喜欢为节点(或簇)选择随机中等强度的颜色,并使节点背景成为该颜色的较亮版本,并使退出的边缘成为该颜色的较暗版本。

例如,在java中我有两个这样的工具方法。

public static Color hashColor(Object value) { 
    if (value == null) { 
     return Color.WHITE.darker(); 
    } else { 
     int r = 0xff - (Math.abs(1 + value.hashCode()) % 0xce); 
     int g = 0xff - (Math.abs(1 + value.hashCode()) % 0xdd); 
     int b = 0xff - (Math.abs(1 + value.hashCode()) % 0xec); 
     return new Color(r, g, b); 
    } 
}   

/** 
* @return a hex Color string in the format #rrggbb. 
*/ 
public static String encodeColor(Color color) { 
    return "#" + String.format("%06x", color.getRGB() & 0xffffff); 

} 
1

我有一个类似的问题,我有一个节点的负载节点出来。

我用sfdp(点无法处理节点的数量)和-Goverlap = prism选项,这很好地分开了事情。

1

你这里由GraphViz的接受所有颜色的列表:http://www.graphviz.org/doc/info/colors.html

如果您生成自己的程序的图形,以简单的方式具有独特的颜色是把所有这些颜色在列表中,并在有新的边缘时从这个列表中选择一个。像这样的伪代码:

List colors = {red, blue, green, ...}; 
for edge in edges: 
    write(edge.source + 
      " -> " + 
      edge.sink + 
      " [color=\"" + 
      color.next() + 
      "\"];\n" 
    ); 

更干净的方法是从RGB代码中定义颜色。你可以这样做是这样的:

digraph G 
{ 

    A -> B 
    [ 
     color="#AABBCC" 
    ] 

} 

现在你需要做的是为您的所有边缘之间的十六进制数#000000和#FFFFFF。颜色格式在文档中提供:http://www.graphviz.org/doc/info/attrs.html#k:color