From fe586e6d9a26cd53b9f29b54f7f1a3eaaa2dc9cf Mon Sep 17 00:00:00 2001 From: Kim Morrison Date: Tue, 29 Oct 2024 15:32:28 +1100 Subject: [PATCH] node shapes to indicate --to and --from --- ImportGraph/Cli.lean | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ImportGraph/Cli.lean b/ImportGraph/Cli.lean index be87575..89ef5da 100644 --- a/ImportGraph/Cli.lean +++ b/ImportGraph/Cli.lean @@ -28,22 +28,24 @@ def asDotGraph (unused : NameSet := {}) (header := "import_graph") (markedPackage : Option Name := none) - (directDeps : NameSet := {}) : + (directDeps : NameSet := {}) + (from_ to : NameSet := {}): String := Id.run do let mut lines := #[s!"digraph \"{header}\" " ++ "{"] for (n, is) in graph do + let shape := if from_.contains n then "invhouse" else if to.contains n then "house" else "ellipse" if markedPackage.isSome ∧ directDeps.contains n then -- note: `fillcolor` defaults to `color` if not specified let fill := if unused.contains n then "#e0e0e0" else "white" - lines := lines.push s!" \"{n}\" [style=filled, fontcolor=\"#4b762d\", color=\"#71b144\", fillcolor=\"{fill}\", penwidth=2];" + lines := lines.push s!" \"{n}\" [style=filled, fontcolor=\"#4b762d\", color=\"#71b144\", fillcolor=\"{fill}\", penwidth=2, shape={shape}];" else if unused.contains n then - lines := lines.push s!" \"{n}\" [style=filled, fillcolor=\"#e0e0e0\"];" + lines := lines.push s!" \"{n}\" [style=filled, fillcolor=\"#e0e0e0\", shape={shape}];" else if isInModule markedPackage n then -- mark node - lines := lines.push s!" \"{n}\" [style=filled, fillcolor=\"#96ec5b\"];" + lines := lines.push s!" \"{n}\" [style=filled, fillcolor=\"#96ec5b\", shape={shape}];" else - lines := lines.push s!" \"{n}\";" + lines := lines.push s!" \"{n}\" [shape={shape}];" -- Then add edges for i in is do if isInModule markedPackage n then @@ -148,6 +150,7 @@ def importGraphCLI (args : Cli.Parsed) : IO UInt32 := do let mut outFiles : Std.HashMap String String := {} if extensions.contains "dot" then let dotFile := asDotGraph graph (unused := unused) (markedPackage := markedPackage) (directDeps := directDeps) + (to := NameSet.ofArray to) (from_ := NameSet.ofArray (from?.getD #[])) outFiles := outFiles.insert "dot" dotFile if extensions.contains "gexf" then -- filter out the top node as it makes the graph less pretty