<commit_before>/**
 * Graphology Force Layout Iteration
 * ==================================
 *
 * Function describing a single iteration of the force layout.
 */
const {
  createNodeValueGetter,
  createEdgeValueGetter
} = require('graphology-utils/getters');

// const EPSILON = -Infinity;

// function isVeryCloseToZero(x) {
//   return Math.abs(x) < EPSILON;
// }

module.exports = function iterate(graph, nodeStates, params) {
  const {nodeXAttribute: xKey, nodeYAttribute: yKey} = params;
  const {attraction, repulsion, gravity, inertia, maxMove} = params.settings;

  let {shouldSkipNode, shouldSkipEdge, isNodeFixed} = params;

  isNodeFixed = createNodeValueGetter(isNodeFixed);
  shouldSkipNode = createNodeValueGetter(shouldSkipEdge, false);
  shouldSkipEdge = createEdgeValueGetter(shouldSkipEdge, false);

  const nodes = graph.filterNodes((n, attr) => {
    return !shouldSkipNode.fromEntry(n, attr);
  });

  const adjustedOrder = nodes.length;

  // Check nodeStatess and inertia
  for (let i = 0; i < adjustedOrder; i++) {
    const n = nodes[i];
    const attr = graph.getNodeAttributes(n);
    const nodeState = nodeStates[n];

    if (!nodeState)
      nodeStates[n] = {
        dx: 0,
        dy: 0,
        x: attr[xKey] || 0,
        y: attr[yKey] || 0
      };
    else<commit_msg>[layout-force] fixing shouldSkipNode as per @sim51 indicated Fixes #343<commit_after>/**
 * Graphology Force Layout Iteration
 * ==================================
 *
 * Function describing a single iteration of the force layout.
 */
const {
  createNodeValueGetter,
  createEdgeValueGetter
} = require('graphology-utils/getters');

// const EPSILON = -Infinity;

// function isVeryCloseToZero(x) {
//   return Math.abs(x) < EPSILON;
// }

module.exports = function iterate(graph, nodeStates, params) {
  const {nodeXAttribute: xKey, nodeYAttribute: yKey} = params;
  const {attraction, repulsion, gravity, inertia, maxMove} = params.settings;

  let {shouldSkipNode, shouldSkipEdge, isNodeFixed} = params;

  isNodeFixed = createNodeValueGetter(isNodeFixed);
  shouldSkipNode = createNodeValueGetter(shouldSkipNode, false);
  shouldSkipEdge = createEdgeValueGetter(shouldSkipEdge, false);

  const nodes = graph.filterNodes((n, attr) => {
    return !shouldSkipNode.fromEntry(n, attr);
  });

  const adjustedOrder = nodes.length;

  // Check nodeStatess and inertia
  for (let i = 0; i < adjustedOrder; i++) {
    const n = nodes[i];
    const attr = graph.getNodeAttributes(n);
    const nodeState = nodeStates[n];

    if (!nodeState)
      nodeStates[n] = {
        dx: 0,
        dy: 0,
        x: attr[xKey] || 0,
        y: attr[yKey] || 0
      };
    else
{'fraction_non_alphanumeric': 0.14408682634730538, 'fraction_numerical': 0.00561377245508982, 'mean_word_length': 3.773214285714286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2460156', 'n_tokens_mistral': 854, 'n_tokens_neox': 821, 'n_words': 209}