Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
710 B

  1. (function() {
  2. 'use strict';
  3. if (typeof sigma === 'undefined')
  4. throw 'sigma is not declared';
  5. sigma.utils.pkg('sigma.plugins');
  6. var _id = 0,
  7. _cache = {};
  8. /**
  9. * This function will change size for all nodes depending to their degree
  10. *
  11. * @param {sigma} s The related sigma instance.
  12. * @param {object} initialSize Start size property
  13. */
  14. sigma.plugins.relativeSize = function(s, initialSize) {
  15. var nodes = s.graph.nodes();
  16. // second create size for every node
  17. for(var i = 0; i < nodes.length; i++) {
  18. var degree = s.graph.degree(nodes[i].id);
  19. nodes[i].size = initialSize * Math.sqrt(degree);
  20. }
  21. s.refresh();
  22. };
  23. }).call(window);