colorsgraphvizdisplaydisablesubgraph

graphviz: is there a way to display only a subset of the subgraphs I have defined or have a B&W version(disable colors)?


are they easy ways

  1. to display only a subset of the subgraphs I have defined without commenting or else?
  2. to disable all colors/have a black and white version of the graph

thanks

P.S: it is for teaching/presentation purpose


Solution

  • The layers feature (https://graphviz.org/faq/#FaqOverlays) is the "best" way to produce a subset graph. But there are severl oddities in the implementation (e.g. https://forum.graphviz.org/t/stupid-dot-tricks-2-making-a-video/109) that make it a bit of a pain. An example:

    digraph CL {
      graph [layers="A:C:D"]
    
      subgraph cluster1{
        node [layer="A,C,D"]
        a->b->c->{e f}
      }
      subgraph cluster11{
        node [layer="C,D"]
        ax->bx->{cx ex fx}
      }
      subgraph cluster12{
        node [layer="D"]
        ay->{by cy ey fy}
      }
      subgraph clusterZAZ{
        node [layer="A,D"]
        a55->{b55 c55 e55 frrrr}
      }
      // comment out the next line and see what happens
      edge [layer=D]  // this should not be necessary
      ax->by
    }
    

    Here is a command line to produce layer C:

    dot -Tsvg -Glayerselect=C clusterLayers.gv >C.svg
    

    Maybe Inkscape (https://inkscape.org/) convert a colored SVG graph to black-and-white