

OGDF C++ library provides some graph generators, I made it possible to use them from terminal, not by writing C++ client code. Got some pleasant pictures, here they are.
- Graphs of ~32 nodes, FMMM layout.
- Graphs of ~512 nodes, FMMM layout.
- Graphs of ~512 nodes, ForceAtlas2 layout.
Each node is labeled by it’s degree - count of incoming/outgoing edges. Colored accordingly, from blue to red.
Powershell code for creating these pictures goes like that:
# define params for each generator
$genLines = @'
complement --n 32 --directed false --allowSelfLoops false
regularLatticeGraph --n 32 --k 4
regularTree --n 32 --children 2
completeGraph --n 32
completeBipartiteGraph --n 16 --m 16
wheelGraph --n 32
cubeGraph --n 5
globeGraph --meridians 8 --latitudes 4
suspension --s 32
gridGraph --n 8 --m 4 --loopN false --loopM false
petersenGraph --n 16 --m 2
emptyGraph --nodes 32
randomRegularGraph --n 32 --d 4
randomGraph --n 32 --m 100
randomSimpleGraph --n 32 --m 100
randomSimpleGraphByProbability --n 32 --pEdge 0.2
randomSimpleConnectedGraph --n 32 --m 50
randomBiconnectedGraph --n 32 --m 60
randomPlanarConnectedGraph --n 32 --m 60
randomPlanarBiconnectedGraph --n 32 --m 60 --multiEdges false
randomPlanarBiconnectedDigraph --n 32 --m 60 --p 0.0 --multiEdges false
randomUpwardPlanarBiconnectedDigraph --n 32 --m 60
randomPlanarCNBGraph --n 32 --m 60 --b 5
randomTriconnectedGraph --n 32 --p1 0.5 --p2 0.5
randomPlanarTriconnectedGraph --n 32 --m 80
randomPlanarTriconnectedGraph --n 32 --p1 0.3 --p2 0.3
randomTree --n 32
randomTree --n 32 --maxDeg 4 --maxWidth 10
randomDigraph --n 32 --p 0.1
randomSeriesParallelDAG --edges 60 --p 0.5 --flt 0.0
randomGeometricCubeGraph --nodes 32 --threshold 0.3 --dimension 2
randomWaxmanGraph --nodes 32 --alpha 0.5 --beta 0.2 --width 1.0 --height 1.0
preferentialAttachmentGraph --nodes 32 --minDegree 2
randomWattsStrogatzGraph --n 32 --k 4 --probability 0.3
randomHierarchy --n 32 --m 3 --planar true --singleSource true --longEdges false
pruneEdges --max_edges 60 --min_deg 2
'@
# generate graphs and layout/render with GephiCommander
$genLines | % {
$genCode = $_ -replace '\s+'
$outFile = Join-Path (gi ./img/) "$genCode$(Get-Date -Format FileDateTime).png"
$generatorArgs = $_ -split ' '
$expr = /bin/echo `& $ogdfCli --generate @generatorArgs --out-file delme.dot
Invoke-Expression $expr
@(
@{op='import'; file='delme.dot' }
@{op='preview'; 'background-color'='#171717'; 'nodeLabelShow'=$true; }
@{op='colorNodesBy';column='degree'; mode='ranking'}
@{op='labelNodesBy';column='degree'; }
@{op='layouts'; values=@(
@{name='ForceAtlas2'; steps=200}
@{name='Expansion'; 'Density'=5000; steps=1; }
)}
@{op='export';file=$outFile; timestamp=$false; resolution=@(512,512); }
) | ConvertTo-Json -d 9 | java -jar $gephiCommander -
$cmdEscaped = $generatorArgs -join ' '
magick $outFile -gravity SouthWest -undercolor "rgba(0,0,0,0.5)" -fill white -pointsize "%[fx:int(h*0.04)]" -annotate +10+10 $cmdEscaped $outFile
}
# Put all pngs into $files var and combine them into a grid
magick montage $files -tile "${cols}x${rows}" -geometry "400x400+2+2" -background "black" "img/grid_output$(Get-Date -Format FileDateTime).png"
You must log in or # to comment.

