水平放置节点外部的集群

时间:2016-01-26 22:50:08

标签: graph graphviz dot

我想在Graphviz中试图制作一个架构图,但无论我尝试什么,dot似乎总是希望用尽可能长的路径连接一些节点。

以下是我希望它或多或少看起来的草图:

Masterly sketch

以下是它的实际外观:

Not so masterly graph

这是有问题的代码:

digraph ngsys {
    graph [dpi = 300];
    rankdir="LR";
    subgraph cluster_client {
        style=filled;
        color=lightgrey;
        node [style=filled, color=white];
        ngcontroller -> ngmodel;
        ngmodel -> ngview;
        label="Client";
    }

    ngview -> user [style=dashed];
    user -> ngcontroller [style=dashed];

    subgraph cluster_server {
        style=filled;
        color=lightgrey;
        node [style=filled, color=white];
        apicontroller -> apimodel;
        label="Server";
    }
    ngcontroller -> apicontroller [label="REST", dir=both, style=dashed];

    ngmodel [label="NG-Model" shape=box];
    user [label="User"];
    ngview [label="NG-View", shape=box];
    ngcontroller [label="NG-Controler", shape=box];
    apicontroller [label="API-Controller", shape=box];
    apimodel [label="API-Model", shape=box];

}

我能做些什么来让输出看起来更像草图吗?

1 个答案:

答案 0 :(得分:1)

稍微更改了订单:

    ngview -> ngmodel [dir=back];
    ngmodel -> ngcontroller [dir=back];

另一个小改变改善了外观:

    nodesep=1;
    ...
    ngview:s -> user [style=dashed];
    user -> ngcontroller:s [style=dashed];