extent.js
function nodeExtent(graph, attribute) {
  if (!isGraph(graph))
    throw new Error('graphology-metrics/extent: the given graph is not a valid graphology instance.');

  var attributes = [].concat(attribute);

  var nodes = graph.nodes(),
      node,
      data,
      value,
      key,
      a,
      i,
      l;

  var results = {};

  for (a = 0; a < attributes.length; a++) {
    key = attributes[a];

    results[key] = [Infinity, -Infinity];
  }

  for (i = 0, l = nodes.length; i < l; i++) {
    node = nodes[i];
    data = graph.getNodeAttributes(node);

    for (a = 0; a < attributes.length; a++) {
      key = attributes[a];
      value = data[key];

      if (value < results[key][0])
        results[key][0] = value;

      if (value > results[key][1])
        results[key][1] = value;
    }
  }

  return typeof attribute === 'string' ? results[attribute] : results;
}
function nodeExtent(graph, attribute) {
  if (!isGraph(graph))
    throw new Error('graphology-metrics/extent: the given graph is not a valid graphology instance.');

  var attributes = [].concat(attribute);

  var nodes = graph.nodes(),
      node,
      data,
      value,
      key,
      a,
      i,
      l;

  var results = {};

  for (a = 0; a < attributes.length; a++) {
    key = attributes[a];

    results[key] = [Infinity, -Infinity];
  }

  for (i = 0, l = nodes.length; i < l; i++) {
    node = nodes[i];
    data = graph.getNodeAttributes(node);

    for (a = 0; a < attributes.length; a++) {
      key = attributes[a];
      value = data[key];

      if (value < results[key][0])
        results[key][0] = value;

      if (value > results[key][1])
        results[key][1] = value;
    }
  }

  return typeof attribute === 'string' ? results[attribute] : results;
}
function nodeExtent ( graph , attribute ) { if ( ! isGraph ( graph ) ) throw new Error ( 'graphology-metrics/extent: the given graph is not a valid graphology instance.' ) ; var attributes = [ ] . concat ( attribute ) ; var nodes = graph . nodes ( ) , node , data , value , key , a , i , l ; var results = { } ; for ( a = 0 ; a < attributes . length ; a ++ ) { key = attributes [ a ] ; results [ key ] = [ Infinity , - Infinity ] ; } for ( i = 0 , l = nodes . length ; i < l ; i ++ ) { node = nodes [ i ] ; data = graph . getNodeAttributes ( node ) ; for ( a = 0 ; a < attributes . length ; a ++ ) { key = attributes [ a ] ; value = data [ key ] ; if ( value < results [ key ] [ 0 ] ) results [ key ] [ 0 ] = value ; if ( value > results [ key ] [ 1 ] ) results [ key ] [ 1 ] = value ; } } return typeof attribute === 'string' ? results [ attribute ] : results ; }
Function returning the extent of the selected node attributes.

@param  {Graph}        graph     - Target graph.
@param  {string|array} attribute - Single or multiple attributes.
@return {array|object}
Function returning the extent of the selected node attributes .