-
Notifications
You must be signed in to change notification settings - Fork 0
Get GraphImage
oliwex edited this page Dec 6, 2021
·
2 revisions
function Get-GraphImage {
Param(
[Alias("GraphRoot")]
$root,
[Alias("GraphMiddle")]
$middle,
[Alias("GraphLeaf")]
$leaf,
[Alias("BasePathToGraphImage")]
$pathToImage
)
$imagePath = Join-Path -Path $pathToImage -ChildPath "$middle.png"
$graphTMP=$null
if ($null -eq $root) #not have boss
{
$graphTMP = graph g {
edge -From $middle -To $leaf
}
}
elseif ($null -eq $leaf) #not have employees below
{
$graphTMP = graph g {
edge -From $root -To $middle
}
}
else #have boss and employees
{
$graphTMP = graph g {
edge -From $root -To $middle
edge -From $middle -To $leaf
}
}
$vizPath = Join-Path -Path $pathToImage -ChildPath "$middle.vz"
Set-Content -Path $vizPath -Value $graphTMP
Export-PSGraph -Source $vizPath -Destination $imagePath
#cleaning
Remove-Item -Path $vizPath
$imagePath
}
- Type - Private
- Input
- $root - root of image
- $middle - middle of image
- $leaf - leaf of image
- $pathToImage - PAth to image where the .vz image of graph will be stored
- Output
- $imagePath - path to image with graph