在GraphViz中显示网络的任意图形节点和边缘

时间:2012-08-26 17:06:16

标签: graph graphviz graph-visualization

我想绘制一个网络,作为完全连接的有向图,具有任意数量的节点和边缘,如图所示。 enter image description here 用GraphViz绘制它的简单方法是什么?

1 个答案:

答案 0 :(得分:1)

graphviz图库有一个非常相似的entry,带有花哨的图形:它就像在生成脚本中用您自己的名称替换名称start等一样简单。将其提供给dot计划。

digraph G {bgcolor="red:cyan" gradientangle=0

    subgraph cluster_0 {
        style=filled;
        color=lightgrey;
        fillcolor="blue:yellow";
        gradientangle=90;
        node [fillcolor="yellow:green" style=filled gradientangle=270] a0;
        node [fillcolor="green:red"] a1;
        node [fillcolor="red:cyan"] a2;
        node [fillcolor="cyan:blue"] a3;

        a0 -> a1 -> a2 -> a3;
        label = "process #1";
    }

    subgraph cluster_1 {
        node [fillcolor="yellow:magenta" 
             style=filled gradientangle=270] b0;
        node [fillcolor="magenta:cyan"] b1;
        node [fillcolor="cyan:red"] b2;
        node [fillcolor="red:blue"] b3;

        b0 -> b1 -> b2 -> b3;
        label = "process #2";
        color=blue
        fillcolor="blue:yellow";
        style=filled;
        gradientangle=90;
    }
    start -> a0;
    start -> b0;
    a1 -> b3;
    b2 -> a3;
    a3 -> a0;
    a3 -> end;
    b3 -> end;

    start [shape=Mdiamond ,
        fillcolor="yellow:brown",
        gradientangle=90,
        style=radial];
    end [shape=Msquare,
        fillcolor="orange:blue",
        style=radial,
        gradientangle=90];
}