Clustered graph drawing

44 views
Skip to first unread message

Nathan Grinsztajn

unread,
Jan 12, 2022, 1:35:57 PM1/12/22
to ogdf
Hello!

Thank you very much for your earlier answer! I'm still experimenting with the ogdf library, and I'm especially trying to reproduce the Figure 17.14 of the documentation. My goal would be to load a GML file with some clusters, and output the type of figure mentioned. Unfortunately, I can't somehow make it work, and I don't find basic illustrations of cluster manipulations in the documentation. Would you have a minimal code example to reproduce the type of figures given in Figure 17.14? This would be of great help!

Thank you very much in advance!
Nathan Grinsztajn

Niko Fink

unread,
Jan 12, 2022, 3:05:47 PM1/12/22
to ogdf
Hey,

have you tried something like the following?

    Graph G;
    ClusterGraph CG(G);
    ClusterGraphAttributes GA(CG, ClusterGraphAttributes::all);
    GraphIO::read(GA, CG, G, "infile.gml");
    ClusterPlanarizationLayout cpl;
    cpl.call(G, GA, CG, true);
    GraphIO::write(GA, "outfile.svg");

Unfortunately, I can't attach example in-/output files thanks to google groups, so please find the gml and svg contents down below...

BR
Niko



Creator "ogdf::GraphIO::writeGML"
graph [
  directed 1
  node [
    id 0
  ]
  node [
    id 1
  ]
  node [
    id 2
  ]
  node [
    id 3
  ]
  node [
    id 4
  ]
  node [
    id 5
  ]
  node [
    id 6
  ]
  node [
    id 7
  ]
  node [
    id 8
  ]
  node [
    id 9
  ]
  node [
    id 10
  ]
  node [
    id 11
  ]
  node [
    id 12
  ]
  edge [
    source 4
    target 0
  ]
  edge [
    source 7
    target 2
  ]
  edge [
    source 3
    target 8
  ]
  edge [
    source 8
    target 7
  ]
  edge [
    source 9
    target 3
  ]
  edge [
    source 9
    target 2
  ]
  edge [
    source 9
    target 1
  ]
  edge [
    source 9
    target 6
  ]
  edge [
    source 10
    target 6
  ]
  edge [
    source 4
    target 6
  ]
  edge [
    source 6
    target 11
  ]
  edge [
    source 12
    target 7
  ]
  edge [
    source 12
    target 5
  ]
  edge [
    source 1
    target 5
  ]
  edge [
    source 7
    target 9
  ]
  edge [
    source 1
    target 11
  ]
  edge [
    source 0
    target 10
  ]
  edge [
    source 2
    target 5
  ]
]
  rootcluster [
    cluster [
      id 1
      vertex "0"
      vertex "1"
      vertex "6"
      vertex "2"
      vertex "5"
    ]
    cluster [
      id 2
      cluster [
        id 3
        vertex "9"
        vertex "11"
        vertex "12"
      ]
      vertex "8"
      vertex "10"
    ]
    vertex "3"
    vertex "4"
    vertex "7"
  ]



<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" version="1.1" baseProfile="full" viewBox="38.5 38.5 786.333 833">
        <g>
                <rect x="0" y="0" width="0" height="0" fill="none" stroke="#808080" stroke-width="1.000000px" />
                <text y="10" x="0" text-anchor="end" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="79.999999999999972" y="610.00000000000011" width="452.08333333333348" height="200" fill="none" stroke="#808080" stroke-width="1.000000px" />
                <text y="600.00000000000011" x="532.08333333333348" text-anchor="end" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="200" y="120" width="433.33333333333348" height="450" fill="none" stroke="#808080" stroke-width="1.000000px" />
                <text y="580" x="633.33333333333348" text-anchor="end" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="240" y="260" width="353.33333333333348" height="270" fill="none" stroke="#808080" stroke-width="1.000000px" />
                <text y="540" x="593.33333333333348" text-anchor="end" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <g>
                        <polygon points="332.083,770,330.833,775,333.333,775," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M332.083,850 L332.083,775" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="492.083,700,497.083,698.75,497.083,701.25," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M743.333,310 L783.333,310 M783.333,310 L783.333,700 M783.333,700 L492.083,700" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="593.333,170,598.333,168.75,598.333,171.25," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M673.333,170 L593.333,170" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="733.333,300,732.083,295,734.583,295," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M583.333,160 L583.333,80 M583.333,80 L733.333,80 M733.333,80 L733.333,295" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="683.333,180,682.083,185,684.583,185," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M490.417,430 L490.417,390 M490.417,390 L553.333,390 M553.333,390 L553.333,220 M553.333,220 L683.333,220 M683.333,220 L683.333,185" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="482.083,690,480.833,685,483.333,685," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M482.083,450 L482.083,685" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="340,690,338.75,685,341.25,685," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M472.083,447.917 L432.083,447.917 M432.083,447.917 L432.083,476.667 M432.083,476.667 L340,476.667 M340,476.667 L340,685" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="144.167,690,142.917,685,145.417,685," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M473.333,430 L473.333,220 M473.333,220 L120,220 M120,220 L120,650 M120,650 L144.167,650 M144.167,650 L144.167,685" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="142.083,700,137.083,701.25,137.083,698.75," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M503.333,170 L40,170 M40,170 L40,700 M40,700 L142.083,700" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="152.083,710,150.833,715,153.333,715," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M322.083,860 L152.083,860 M152.083,860 L152.083,715" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="280,436.667,275,437.917,275,435.417," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M160,690 L160,436.667 M160,436.667 L280,436.667" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="723.333,310,718.333,311.25,718.333,308.75," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M402.083,310 L723.333,310" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="392.083,690,390.833,685,393.333,685," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M392.083,320 L392.083,685" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="382.083,700,377.083,701.25,377.083,698.75," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M342.083,700 L382.083,700" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="492.083,440,497.083,438.75,497.083,441.25," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M733.333,320 L733.333,440 M733.333,440 L492.083,440" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="297.917,446.667,296.667,451.667,299.167,451.667," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M324.167,690 L324.167,650 M324.167,650 L297.917,650 M297.917,650 L297.917,451.667" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="513.333,160,512.083,155,514.583,155," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M342.083,760 L823.333,760 M823.333,760 L823.333,40 M823.333,40 L513.333,40 M513.333,40 L513.333,155" stroke="#000000" stroke-width="1.000000px" />
                </g>
                <g>
                        <polygon points="402.083,700,407.083,698.75,407.083,701.25," stroke="#000000" stroke-width="1.000000px" />
                        <path fill="none" d=" M472.083,700 L402.083,700" stroke="#000000" stroke-width="1.000000px" />
                </g>
        </g>
        <g>
                <rect x="322.08333333333337" y="750.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="332.08333333333337" y="760.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="322.08333333333337" y="690.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="332.08333333333337" y="700.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="472.08333333333337" y="690.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="482.08333333333337" y="700.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="673.33333333333348" y="160" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="683.33333333333348" y="170" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="322.08333333333337" y="850.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="332.08333333333337" y="860.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="382.08333333333337" y="690.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="392.08333333333337" y="700.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="142.08333333333334" y="690.00000000000011" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="152.08333333333334" y="700.00000000000011" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="723.33333333333348" y="300" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="733.33333333333348" y="310" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="573.33333333333348" y="160" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="583.33333333333348" y="170" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="472.08333333333337" y="430.00000000000006" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="482.08333333333337" y="440.00000000000006" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="503.33333333333337" y="160" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="513.33333333333337" y="170" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="280" y="426.66666666666669" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="290" y="436.66666666666669" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
        <g>
                <rect x="382.08333333333337" y="300" width="20" height="20" fill="#FFFFFF" stroke-width="1.000000px" stroke="#000000" />
                <text x="392.08333333333337" y="310" text-anchor="middle" dominant-baseline="middle" font-family="Arial" font-size="10" fill="#000000"></text>
        </g>
</svg>
Reply all
Reply to author
Forward
0 new messages