I am not familiar with cytoscape or Java, so I do not know if there is a way to define a node size which depend on node's degree.
Currently I am using the following:
cytoscapeobj.set_style(
[
{
'selector':node,
'style': {
'font-family': 'helvetica',
'font-size': '20px',
'label': 'data(id)'
}
},
{
'selector': 'edge',
'style': {
'font-family': 'helvetica',
'font-size': '20px',
'width' : 'mapData(weight)' # it is actually not working
}
},
{
'selector': 'node[Degree>0]',
'style': {
'width': '100px',
'height': '100px'
}
},
{
'selector': 'node[Degree>1]',
'style': {
'width': '150px',
'height': '150px'
}
},
{
'selector': 'node[Degree>2]',
'style': {
'width': '200px',
'height': '200px'
}
}
]
)
I have thousands of nodes, some of them has degree 1 (most of them), then I have nodes with degree 2, 3, 4, 5 ,... 100, ...
It would be not easy to add a selector for each of them.
Do you know if there is an easier way to plot any node's degree?
You can define any required parameters in the node's data and then use style mappers to apply that data to style properties like
widthor any other. So your code is actually the right way to do that.It doesn't work because
mapData()anddata()works in a different ways. Whiledata()will just apply thedatavalue to that property, as it does tolabelin your example, themapData()requires additional parameters to be set.Check this out:
In that case,
mapDatawill take the value ofdata.weightand then check where is that value between 0 and 100 and proportionally setwidthto the according value between 1 and 3.In my experience, I find it more convenient to use values, precalculated in the code. So I'd go with creating the
data.widthparam and setting to the desired width and then just map the simpledata()mapper to that value.