I'm trying to draw a molecular similarity network using cytoscape.js. I want to set node size to the amount of edges in network. Now I have network data as JSON Format. I want to now that how set each node size using node degree. Any help is appreciated.
Thanks
There are a few ways to set the sizes of selected nodes in Cytoscape: While selected, you can open the Style tab and set a "bypass" value for Node Size (the third column of settings). This will override any default or mapped values (the first two columns).
In the style control panel, click on the little triangle next to Shape to expand the selector, then select a column, select discrete mapping as mapping type then select a shape for each category of nodes.
¶ Cytoscape is able to display large networks (> 10,000 nodes) while maintaining interactive speed.
In your stylesheet, you can define the style according to degree.
e.g.:
node[[degree = 0]] { /* ... */ }
node[[degree >= 1]][[degree <= 3]] { /* ... */ }
node[[degree >= 4]] { /* ... */ }
Refer to the data selectors and use the [[metadata]] double square brackets.
If you need more precision (i.e. on the JS code level rather than the stylesheet level):
If your graph is static, you could add a degree
data attribute to each node and use a mapper in your stylesheet with that attribute. If your graph is dynamic, you could use the same approach but update the degree
attribute as the graph is modified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With