nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
934 stars 107 forks source link

Changing a fill color yields an entirely separated graph #234

Closed vanniktech closed 2 years ago

vanniktech commented 2 years ago

I change my color using:

-node.add(Color.rgb("#ff8a65").fill())
+node.add(Color.rgb("#ff7043").fill())

I rerun my tests and the fill color is changed correctly.

digraph {
edge ["dir"="forward"]
graph ["dpi"="100","label"="junit12196736198730961453","labelloc"="t","fontsize"="35"]
node ["style"="filled"]
-":app" ["shape"="rectangle","fillcolor"="#ff8a65"]
-":lib1" ["fillcolor"="#ff8a65"]
-":lib" ["fillcolor"="#ff8a65"]
-":lib2" ["fillcolor"="#ff8a65"]
+":app" ["shape"="rectangle","fillcolor"="#ff7043"]
+":lib1" ["fillcolor"="#ff7043"]
+":lib" ["fillcolor"="#ff7043"]
+":lib2" ["fillcolor"="#ff7043"]

However just here things get interesting as there are more changes:

{
edge ["dir"="none"]
graph ["rank"="same"]
+":lib1" ["fillcolor"="#ff7043"]
+":lib" ["fillcolor"="#ff7043"]
+":lib2" ["fillcolor"="#ff7043"]
+":app" -> ":lib1" ["style"="dotted"]
+":app" -> ":lib2" ["style"="dotted"]
+":lib1" -> ":lib"
+":lib2" -> ":lib"
}
":app" -> ":lib1" ["style"="dotted"]
":app" -> ":lib2" ["style"="dotted"]
":lib1" -> ":lib"
":lib2" -> ":lib"
}

Why is :app being removed and all the others are added?

Here's a reproducer: https://github.com/vanniktech/gradle-dependency-graph-generator-plugin/pull/167 and the things I'm showing you can be found at DependencyGraphGeneratorPluginTest#multiProjectIntegrationTest

SimonMarquis commented 2 years ago

Maybe the author can point us to the expected way to query node declarations, meaning nodes without links.

We currently do the following:

graph.rootNodes().filter { it.links().isEmpty() }

https://github.com/vanniktech/gradle-dependency-graph-generator-plugin/pull/168/files#diff-e5b58a907eb180ff6bcb49fee3b5ac93b223b0c517c2efc8e7e1a8265701ee59R82