microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.35k stars 302 forks source link

Self-contained one-stop MSAGL executable #282

Open NikolajBjorner opened 3 years ago

NikolajBjorner commented 3 years ago

A current main use of MSAGL is as a library and it suits this purpose fine as far as I can tell. A different use of MSAGL is as a stand-alone executable. Currently, there is no single executable that adequately represents MSAGL functionality. Test01 has a lot of functionality and can be used both in console (-quiet) and in interactive mode. Until recently it didn't produce svg output. The name Test01.exe also doesn't relate well to what the executable does (draws graphs).

Insofar as MSAGL offers functionality compatible with and in extension to graphwiz it would be useful to have a way to use MSAGL that offers compatible command-line options when applicable.

Such an executable (and nuget packages) can be added to the Azure pipeline so they are accessible on builds.

levnach commented 3 years ago

Started working on it. Created project agl, under "tools", that builds agl.exe. The instruction "agl.exe -file c:/dev/agl/GraphLayout/Test/MSAGLTests/Resources/DotFiles/LevFiles/abstract.dot -svgout c:/tmp/abst.svg -bundling" loads "abstract.dot", calculate the layout, using edge routing with bundles, produces SVG output to "c:/tmp/abst.svg" and pops the UI. If option "-quiet" added then there is no form shown and the process exits. I consider adding support to produce outputs in ".png" format, etc., although, they can be now obtained through UI.

eosfor commented 2 years ago

@NikolajBjorner, I'm trying to play around with MSAGL and make a similar thing here. The purpose of it is being able to build graphs in some scriptable way using PowerShell. Unfortunately, it only works from the dev branch now.

For example, this builds and visualizes the process tree on a windows box:

$ps = Get-CimInstance -ClassName win32_process

$psHash = @{}
foreach ($p in $ps) {
    $psHash[$p.ProcessId] = $p
}

$g = New-Graph
foreach ($p in $ps) {
    if ($psHash[$p.ParentProcessId] -ne $null) {
        add-edge -From $psHash[$p.ParentProcessId] -To $psHash[$p.ProcessId] -Graph $g
    }
}

Export-Graph -Graph $g -Format MSAGL -Path C:\temp\process.svg

Which at the end looks like this.

image