digraph G {
    compound = true;

    /*
    subgraph cluster_project {
        label = "project";
        mode;
        domain;
        create_cluster;
        create_params;
        calc_modf;
        calc_rfac;
        comb_doms;
        comb_scans;
    }
    */

    subgraph cluster_model {
        label = "model handler";
        rank = same;
        model_creator [label="create model", group=creators];
        model_handler [label="evaluate results", group=handlers];

        model_handler -> model_creator [constraint=false, label="optimize"];
    }

    subgraph cluster_domain {
        label = "domain handler";
        rank = same;
        dom_creator [label="expand models", group=creators];
        dom_handler [label="combine domains", group=handlers];
    }

    subgraph cluster_scan {
        label = "scan handler";
        rank = same;
        scan_creator [label="expand models", group=creators];
        scan_handler [label="combine scans", group=handlers];
    }

    subgraph cluster_interface {
        label = "calculator interface"
        rank = same;
        calc_creator [label="generate input", group=creators];
        calc_handler [label="import output", group=handlers];
    }

    calculator [label="calculator (EDAC)", shape=box];

    model_creator -> dom_creator [label="model", style=bold];
    dom_creator -> scan_creator [label="models", style=bold];
    scan_creator -> calc_creator [label="models", style=bold];
    calc_creator -> calculator [label="clusters,\rparameters", style=bold];

    calculator -> calc_handler [label="output files", style=bold];
    calc_handler -> scan_handler [label="raw data files", style=bold];
    scan_handler -> dom_handler [label="combined scans", style=bold];
    dom_handler -> model_handler [label="combined domains", style=bold];

    mode [shape=parallelogram];
    mode -> model_creator [lhead="cluster_model"];

    domain [shape=parallelogram];
    domain -> model_creator;
    //domain -> model_creator [lhead="cluster_model"];

    create_cluster [shape=cds, label="cluster generator"];
    create_cluster -> calc_creator [style=dashed];

    create_params [shape=cds, label="input file generator"];
    create_params -> calc_creator [style=dashed];

    calc_modf [shape=cds, label="modulation function"];
    calc_modf -> model_handler [style=dashed];

    calc_rfac [shape=cds, label="R-factor function"];
    calc_rfac -> model_handler [style=dashed];

    comb_doms [shape=cds, label="domain combination rule"];
    comb_doms -> dom_handler [style=dashed];

    comb_scans [shape=cds, label="scan combination rule"];
    comb_scans -> scan_handler [style=dashed];
}
