function packageImports(nodes) {
  var map = {},
      imports = [];

  // Compute a map from name to node.
  nodes.forEach(function(d) {
    map[d.name] = d;
  });

  // For each import, construct a link from the source to target node.
  nodes.forEach(function(d) {
    if (d.imports) d.imports.forEach(function(b,a) {
      if (b.imports) b.imports.forEach(function(i, m) {
        var t = jQuery.extend({}, map[i]); // Shallow copy object to not modify original object
        t.id = b.id;
        t.depth_ = b.depth;
        imports.push({source: map[d.name], target: t});
      });

      // add fta ids to node for better selection
      var t = map[d.name];
      if(t.id) {
        // only add if not already exist
        var found = -1;
        t.id.forEach(function(e,i) { if(e == b.id) found = i; });
        if(found == -1) t.id.push(b.id);
      }
      else t.id = [b.id];
    });
  });
  return imports;
}
// Return a list of imports for the given array of nodes.
Return a list of imports for the given array of nodes.
Return a list of imports for the given array of nodes .
function packageImports(nodes) {
  var map = {},
      imports = [];
  nodes.forEach(function(d) {
    map[d.name] = d;
  });
  nodes.forEach(function(d) {
    if (d.imports) d.imports.forEach(function(b,a) {
      if (b.imports) b.imports.forEach(function(i, m) {
        var t = jQuery.extend({}, map[i]); 
        t.id = b.id;
        t.depth_ = b.depth;
        imports.push({source: map[d.name], target: t});
      });
      var t = map[d.name];
      if(t.id) {
        var found = -1;
        t.id.forEach(function(e,i) { if(e == b.id) found = i; });
        if(found == -1) t.id.push(b.id);
      }
      else t.id = [b.id];
    });
  });
  return imports;
}
function packageImports ( nodes ) { var map = { } , imports = [ ] ; nodes . forEach ( function ( d ) { map [ d . name ] = d ; } ) ; nodes . forEach ( function ( d ) { if ( d . imports ) d . imports . forEach ( function ( b , a ) { if ( b . imports ) b . imports . forEach ( function ( i , m ) { var t = jQuery . extend ( { } , map [ i ] ) ; t . id = b . id ; t . depth_ = b . depth ; imports . push ( { source : map [ d . name ] , target : t } ) ; } ) ; var t = map [ d . name ] ; if ( t . id ) { var found = - 1 ; t . id . forEach ( function ( e , i ) { if ( e == b . id ) found = i ; } ) ; if ( found == - 1 ) t . id . push ( b . id ) ; } else t . id = [ b . id ] ; } ) ; } ) ; return imports ; }
Return a list of imports for the given array of nodes.
Return a list of imports for the given array of nodes .
// Compute a map from name to node. // For each import, construct a link from the source to target node. // Shallow copy object to not modify original object // add fta ids to node for better selection // only add if not already exist