addon/utils/graph-view.js
function _normalize(nodes) {
  // Set layout
  var farthestY = 0;
  nodes.forEach(function (d) {
    d.y = d.depth * -_layout.depthSpacing;
    if(d.y < farthestY) {
      farthestY = d.y;
    }
  });

  farthestY -= PADDING;
  nodes.forEach(function (d) {
    d.y -= farthestY;
  });

  //Remove space occupied by dummy
  var rootChildren = _treeData.get('children'),
      rootChildCount = rootChildren.length,
      dummyIndex,
      i;

  if(rootChildCount % 2 === 0) {
    dummyIndex = rootChildren.indexOf(_treeData.get('dummy'));
    if(dummyIndex >= rootChildCount / 2) {
      for(i = 0; i < dummyIndex; i++) {
        rootChildren[i].x = rootChildren[i + 1].x;
        rootChildren[i].y = rootChildren[i + 1].y;
      }
    }
    else {
      for(i = rootChildCount - 1; i > dummyIndex; i--) {
        rootChildren[i].x = rootChildren[i - 1].x;
        rootChildren[i].y = rootChildren[i - 1].y;
      }
    }
  }

  // Put all single vertex outputs in-line with the vertex node
  // So that they are directly below the respective vertex in vertical layout
  nodes.forEach(function (node) {
    if(node.type === DataProcessor.types.OUTPUT &&
        node.get('vertex.outputs.length') === 1 &&
        !node.get('vertex.outEdgeIds.length') &&
        node.get('treeParent.x') !== node.get('x')
    ) {
      node.x = node.get('vertex.x');
    }
  });
}
function _normalize(nodes) {
  // Set layout
  var farthestY = 0;
  nodes.forEach(function (d) {
    d.y = d.depth * -_layout.depthSpacing;
    if(d.y < farthestY) {
      farthestY = d.y;
    }
  });

  farthestY -= PADDING;
  nodes.forEach(function (d) {
    d.y -= farthestY;
  });

  //Remove space occupied by dummy
  var rootChildren = _treeData.get('children'),
      rootChildCount = rootChildren.length,
      dummyIndex,
      i;

  if(rootChildCount % 2 === 0) {
    dummyIndex = rootChildren.indexOf(_treeData.get('dummy'));
    if(dummyIndex >= rootChildCount / 2) {
      for(i = 0; i < dummyIndex; i++) {
        rootChildren[i].x = rootChildren[i + 1].x;
        rootChildren[i].y = rootChildren[i + 1].y;
      }
    }
    else {
      for(i = rootChildCount - 1; i > dummyIndex; i--) {
        rootChildren[i].x = rootChildren[i - 1].x;
        rootChildren[i].y = rootChildren[i - 1].y;
      }
    }
  }

  // Put all single vertex outputs in-line with the vertex node
  // So that they are directly below the respective vertex in vertical layout
  nodes.forEach(function (node) {
    if(node.type === DataProcessor.types.OUTPUT &&
        node.get('vertex.outputs.length') === 1 &&
        !node.get('vertex.outEdgeIds.length') &&
        node.get('treeParent.x') !== node.get('x')
    ) {
      node.x = node.get('vertex.x');
    }
  });
}
function _normalize ( nodes ) { // Set layout var farthestY = 0 ; nodes . forEach ( function ( d ) { d . y = d . depth * - _layout . depthSpacing ; if ( d . y < farthestY ) { farthestY = d . y ; } } ) ; farthestY -= PADDING ; nodes . forEach ( function ( d ) { d . y -= farthestY ; } ) ; //Remove space occupied by dummy var rootChildren = _treeData . get ( 'children' ) , rootChildCount = rootChildren . length , dummyIndex , i ; if ( rootChildCount % 2 === 0 ) { dummyIndex = rootChildren . indexOf ( _treeData . get ( 'dummy' ) ) ; if ( dummyIndex >= rootChildCount / 2 ) { for ( i = 0 ; i < dummyIndex ; i ++ ) { rootChildren [ i ] . x = rootChildren [ i + 1 ] . x ; rootChildren [ i ] . y = rootChildren [ i + 1 ] . y ; } } else { for ( i = rootChildCount - 1 ; i > dummyIndex ; i -- ) { rootChildren [ i ] . x = rootChildren [ i - 1 ] . x ; rootChildren [ i ] . y = rootChildren [ i - 1 ] . y ; } } } // Put all single vertex outputs in-line with the vertex node // So that they are directly below the respective vertex in vertical layout nodes . forEach ( function ( node ) { if ( node . type === DataProcessor . types . OUTPUT && node . get ( 'vertex.outputs.length' ) === 1 && ! node . get ( 'vertex.outEdgeIds.length' ) && node . get ( 'treeParent.x' ) !== node . get ( 'x' ) ) { node . x = node . get ( 'vertex.x' ) ; } } ) ; }
Apply proper depth spacing and remove the space occupied by dummy node
if the number of other nodes are odd.
@param nodes {Array} A list of d3 nodes created by tree layout
Apply proper depth spacing and remove the space occupied by dummy node if the number of other nodes are odd .