0

我试图在节点标签下显示状态的属性。

目前是这样的:

 ________________________               ________________________
|                        |    pause()  |                        |
|                        |------------>|                        |
|                        |  continue() |                        |
|________________________|<------------|________________________|

我有代码:

        Graph = new Graph<State>();
        var a = new State()
        {
            Status = "Ready",
            AllowedPurchaserOperations = "operation1, operation2",
            AllowedSupplierOperations = "operarion1, operation 3"
        };
        var b = new State()
        {
            Status = "Paused",
            AllowedPurchaserOperations = "operation1, operation2",
            AllowedSupplierOperations = "operarion1, operation 3"
        };

        Graph.AddVertex(a);
        Graph.AddVertex(b);

        Graph.AddEdge(new Edge<State>(a, b) {Label = "pause()"});
        Graph.AddEdge(new Edge<State>(b, a) {Label = "continue()"});

我想或多或少地像这样展示它:

 ________________________               ________________________
|         Ready          |    pause()  |         Paused         |
| operation1, operation2 |------------>| operation1, operation2 |
| operation1, operation3 |  continue() | operation1, operation3 |
|________________________|<------------|________________________|

由于很难找到使用 graphviz 的实现示例,我不知道如何在节点中添加值。有人知道在转换之前我应该​​做什么吗?

4

1 回答 1

1

我对graphviz4net一无所知,但这很容易通过使用Graphviz的DOT语言实现集群

图形

该图的 DOT 文件如下:

digraph g{

    // Set the graph direction from left to right
    // otherwise the boxes will be above eachother
    // with the arrows pointing up and down
    rankdir="LR"

    // hide the border of the nodes in the cluster supgraph
    node [shape = "none"]

    // make the lines dashed, remove if you want solid lines
    edge [style = "dashed"]

    subgraph cluster_ready {
        label = "Ready"

        ready_op_1_2 [label="operation1, operation2"]
        ready_op_1_3 [label="operation1, operation3"]
    }

    subgraph cluster_paused {
        label = "Paused"

        paused_op_1_2 [label="operation1, operation2"]
        paused_op_1_3 [label="operation1, operation3"]
    }

    ready_op_1_2 -> paused_op_1_2 [label="pause()"]
    paused_op_1_3 -> ready_op_1_3 [label="continue()"]
}

您可以通过更改各种元素的字体、颜色和样式来相当轻松地调整外观。为了解决这个问题,我建议使用GraphViz Workspace来快速了解哪个属性(以及它的设置)的作用。属性手册可能有点压倒性,但它有你需要的一切。

于 2013-10-13T19:51:57.077 回答