extent.js
function edgeExtent(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 edges = graph.edges(),
      edge,
      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 = edges.length; i < l; i++) {
    edge = edges[i];
    data = graph.getEdgeAttributes(edge);

    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 edgeExtent(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 edges = graph.edges(),
      edge,
      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 = edges.length; i < l; i++) {
    edge = edges[i];
    data = graph.getEdgeAttributes(edge);

    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 edgeExtent ( 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 edges = graph . edges ( ) , edge , 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 = edges . length ; i < l ; i ++ ) { edge = edges [ i ] ; data = graph . getEdgeAttributes ( edge ) ; 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 edge attributes.

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