<commit_before>HTMLWidgets.widget({

  name: "sigma",

  type: "output",
  
  initialize: function(el, width, height) {
    
    // neighbors function
    sigma.classes.graph.addMethod('neighbors', function(nodeId) {
    var k,
        neighbors = {},
        index = this.allNeighborsIndex[nodeId] || {};

    for (k in index)
      neighbors[k] = this.nodesIndex[k];

    return neighbors;
    });
    
    console.log("this is the init height:"+height+" and width" + width)
    // create our sigma object and bind it to the element
    var sig = new sigma(el.id);

    // return it as part of our instance data
    return {
      sig: sig
    };
  },

  renderValue: function(el, x, instance) {

    // parse gexf data
    var parser = new DOMParser();
    var data = parser.parseFromString(x.data, "application/xml");

    // apply settings
    for (var name in x.settings){
      console.log(name);
      instance.sig.settings(name, x.settings[name]);
    }
    


    // update the sigma instance
    sigma.parsers.gexf(
      data,          // parsed gexf data
      instance.sig,  // sigma instance we created in initialize
      function(s) {
         // We first need to save the original colors of our
      // nodes and edges, like this:
      s.graph.nodes().forEach(function(n) {
        console.log(n.color);
        n.originalColor = n.color;
      });
      s.graph.edges().forEach(function(e) {
        e.originalColor = e.color;
      });<commit_msg>Update sigma.js<commit_after>HTMLWidgets.widget({

  name: "sigma",

  type: "output",
  
  initialize: function(el, width, height) {
    
    // neighbors function
    sigma.classes.graph.addMethod('neighbors', function(nodeId) {
    var k,
        neighbors = {},
        index = this.allNeighborsIndex[nodeId] || {};

    for (k in index)
      neighbors[k] = this.nodesIndex[k];

    return neighbors;
    });
    
    console.log("this is the init height:"+height+" and width" + width)
    // create our sigma object and bind it to the element
    var sig = new sigma(el.id);

    // return it as part of our instance data
    return {
      sig: sig
    };
  },

  renderValue: function(el, x, instance) {

    // parse gexf data
    var parser = new DOMParser();
    var data = parser.parseFromString(x.data, "application/xml");

    // apply settings
    for (var name in x.settings){
      console.log(name);
      instance.sig.settings(name, x.settings[name]);
    }
    


    // update the sigma instance
    sigma.parsers.gexf(
      data,          // parsed gexf data
      instance.sig,  // sigma instance we created in initialize
      function(s) {
         // We first need to save the original colors of our
      // nodes and edges, like this:
      s.graph.nodes().forEach(function(n) {
        console.log(n.color);
        n.originalColor = "rgb(190,190,190,0.1)"
        //n.color;
      });
      s.graph.edges().forEach(function(e) {
        e.originalColor = e.color;
      });
{'fraction_non_alphanumeric': 0.12815338042381433, 'fraction_numerical': 0.003699966363942146, 'mean_word_length': 2.201291711517761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '630806', 'n_tokens_mistral': 943, 'n_tokens_neox': 901, 'n_words': 248}