Graphviz: De-duplicate node names in dot file

This commit is contained in:
Wang Xinyu
2025-12-06 10:49:24 +01:00
committed by Brad King
parent 0439baaad1
commit 6917f6d453
3 changed files with 6 additions and 9 deletions

View File

@@ -7,6 +7,7 @@
#include <iostream>
#include <memory>
#include <set>
#include <unordered_set>
#include <utility>
#include <cm/memory>
@@ -367,10 +368,14 @@ void cmGraphVizWriter::WritePerTargetConnections(
std::unique_ptr<cmGeneratedFileStream> fileStream =
this->CreateTargetFile(rootItem, fileNameSuffix);
// avoid write same node multiple times
std::unordered_set<std::string> writtenNodes = { rootItem.AsStr() };
for (Connection const& con : cons) {
cmLinkItem const& src = DirFunc::src(con);
cmLinkItem const& dst = DirFunc::dst(con);
this->WriteNode(*fileStream, con.dst);
if (writtenNodes.emplace(con.dst.AsStr()).second) {
this->WriteNode(*fileStream, con.dst);
}
this->WriteConnection(*fileStream, src, dst, con.scopeType);
}

View File

@@ -11,15 +11,12 @@ node [
"node2" -> "node3" [ style = dotted ] // CoreLibrary -> GoofyLoggingLibrary
"node4" [ label = "SystemLibrary", shape = octagon ];
"node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary
"node2" [ label = "CoreLibrary", shape = octagon ];
"node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary
"node7" [ label = "GraphicLibrary", shape = doubleoctagon ];
"node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary
"node8" [ label = "\"-lm\"", shape = septagon ];
"node7" -> "node8" [ style = dotted ] // GraphicLibrary -> "-lm"
"node0" [ label = "CompilerFlags", shape = pentagon ];
"node7" -> "node0" // GraphicLibrary -> CompilerFlags
"node2" [ label = "CoreLibrary", shape = octagon ];
"node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary
"node9" [ label = "GraphicLibraryObjects", shape = hexagon ];
"node7" -> "node9" [ style = dotted ] // GraphicLibrary -> GraphicLibraryObjects

View File

@@ -7,7 +7,6 @@ node [
"node2" -> "node0" // CoreLibrary -> CompilerFlags
"node4" [ label = "SystemLibrary", shape = octagon ];
"node4" -> "node2" [ style = dotted ] // SystemLibrary -> CoreLibrary
"node2" [ label = "CoreLibrary", shape = octagon ];
"node2" -> "node4" [ style = dotted ] // CoreLibrary -> SystemLibrary
"node1" [ label = "ConsoleApplication", shape = egg ];
"node1" -> "node2" [ style = dotted ] // ConsoleApplication -> CoreLibrary
@@ -15,16 +14,12 @@ node [
"node6" -> "node2" [ style = dotted ] // GraphicApplication -> CoreLibrary
"node7" [ label = "GraphicLibrary", shape = doubleoctagon ];
"node7" -> "node2" [ style = dotted ] // GraphicLibrary -> CoreLibrary
"node6" [ label = "GraphicApplication", shape = egg ];
"node6" -> "node7" [ style = dotted ] // GraphicApplication -> GraphicLibrary
"node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ];
"node10" -> "node2" [ style = dotted ] // GraphicDriverOpenGL -> CoreLibrary
"node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
"node11" -> "node2" [ style = dotted ] // GraphicDriverVulkan -> CoreLibrary
"node7" [ label = "GraphicLibrary", shape = doubleoctagon ];
"node7" -> "node0" // GraphicLibrary -> CompilerFlags
"node10" [ label = "GraphicDriverOpenGL", shape = tripleoctagon ];
"node10" -> "node0" [ style = dotted ] // GraphicDriverOpenGL -> CompilerFlags
"node11" [ label = "GraphicDriverVulkan", shape = tripleoctagon ];
"node11" -> "node0" [ style = dotted ] // GraphicDriverVulkan -> CompilerFlags
}