Vis.js – how to draw the size of a node that determined by the number of links?

I’m drawing a graph using vis.js and I want the node size to be determined by the number of links: the more connections, the larger the node. Unfortunately, I don’t know javascript very well and I can’t create such a function myself, please help.

For example, here 2 nodes of the same group are in red and their size is determined by the number of links

In the documentation, I found only how to change a fixed size, or set a function that changes the size within min and max.