group nodes with subgraphs

Reactormonk picture Reactormonk · Jul 11, 2012 · Viewed 10.9k times · Source

I'd like to group some nodes with the following code

digraph dataflow {
    subgraph pipeline {
        relations;
        synonyms;
        articles;
    }
    subgraph lucene {
        index;
        search;
    }
    training_data - > index;
    relations - > search;
    synonyms - > index;
    articles - > index;
    training_data - > evaluation;
}

But dot doesn't care about the subgraphs:

example dot graph

Answer

Rick picture Rick · Jul 11, 2012

Try prefixing your subgraphs with 'cluster_':

digraph dataflow {
    subgraph cluster_pipeline {
        relations;
        synonyms;
        articles;
    }
    subgraph cluster_lucene {
        index;
        search;
    }
    training_data -> index;
    relations -> search;
    synonyms -> index;
    articles -> index;
    training_data -> evaluation;
}