graphstream / gs-core

Graphstream core
http://graphstream-project.org/
Other
398 stars 109 forks source link

Graph styling, unable to find documented method #351

Closed DanySK closed 3 years ago

DanySK commented 3 years ago

Hi, I'm trying to style nodes in such a way that their size is proportional to some property (harmonic centrality, or degree, or just their index). I'm following the guide at https://graphstream-project.org/doc/Tutorials/Graph-Visualisation/, but the Graph interface does not expose any addAttribute method to set the CSS. I can only add sinks.

What is the quickest method to add a different size (and color, maybe) to a node? Thanks

pigne commented 3 years ago

Docs are being updated. addAttribute was an alias to setAttribute and as been removed in 2.0. Just replace addAttribute with setAttribute.

DanySK commented 3 years ago

Thanks! I was also able to set attributes node by node. The CSS attribute is ui.style, so in order to set nodes as big as their edge count, one way is:

graph.forEach { it.setAttribute("ui.style", "size: ${it.edges().count()}px;") }