-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to export CFGs to Graphviz DOT graphs (#152)
* Add ability to export CFG to Graphviz DOT format * Save to DOT with block labels over instead of IDs * Update version
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved. | ||
|
||
import { JsonSDFGControlFlowRegion, JsonSDFGEdge } from '../..'; | ||
|
||
function cfgEdgeToDotGraphEdge( | ||
cfg: JsonSDFGControlFlowRegion, edge: JsonSDFGEdge | ||
): string { | ||
const srcName = cfg.nodes[Number(edge.src)].label; | ||
const dstName = cfg.nodes[Number(edge.dst)].label; | ||
return srcName + ' -> ' + dstName; | ||
} | ||
|
||
export function cfgToDotGraph(cfg: JsonSDFGControlFlowRegion): string { | ||
let graphString = ''; | ||
|
||
graphString += 'digraph "' + (cfg.attributes?.name ?? 'program') + '" {\n'; | ||
|
||
for (const edge of cfg.edges) | ||
graphString += ' ' + cfgEdgeToDotGraphEdge(cfg, edge) + '\n'; | ||
|
||
graphString += '}\n'; | ||
|
||
return graphString; | ||
} |