function computeNodeBreadths() {
    var remainingNodes = nodes,
        nextNodes,
        x = 0;

    function updateNode(node) {
        // Set x-position and width:
        node.x = x;
        node.dx = nodeWidth;
        node.sourceLinks.forEach(function(link) {
          // Only add it to the nextNodes list if it is not already present:
          if (nextNodes.indexOf(link.target) === -1) {
            nextNodes.push(link.target);
          }
        });
    }

    // Work from left to right.
    // Keep updating the breadth (x-position) of nodes that are targets of
    // recently-updated nodes.
    while (remainingNodes.length && x < nodes.length) {
      nextNodes = [];
      remainingNodes.forEach(updateNode);
      remainingNodes = nextNodes;
      x += 1;
    }

    // Move endpoint nodes all the way to the right?
    if (rightJustifyEndpoints) {
      moveSinksRight(x - 1);
    }

    // Let origins appear just before their first target node?
    // (In this case, we have to do extra work to *not* justify these nodes.)
    if (!leftJustifyOrigins) {
      moveOriginsRight();
    }

    // Apply a scaling factor to the breadths to spread them evenly across the canvas:
    scaleNodeBreadths( (size[0] - nodeWidth) / (x - 1) );
  }
// nodes with no outgoing links are assigned the maximum breadth.
nodes with no outgoing links are assigned the maximum breadth.
nodes with no outgoing links are assigned the maximum breadth .
function computeNodeBreadths() {
    var remainingNodes = nodes,
        nextNodes,
        x = 0;
    function updateNode(node) {
        node.x = x;
        node.dx = nodeWidth;
        node.sourceLinks.forEach(function(link) {
          if (nextNodes.indexOf(link.target) === -1) {
            nextNodes.push(link.target);
          }
        });
    }
    while (remainingNodes.length && x < nodes.length) {
      nextNodes = [];
      remainingNodes.forEach(updateNode);
      remainingNodes = nextNodes;
      x += 1;
    }
    if (rightJustifyEndpoints) {
      moveSinksRight(x - 1);
    }
    if (!leftJustifyOrigins) {
      moveOriginsRight();
    }
    scaleNodeBreadths( (size[0] - nodeWidth) / (x - 1) );
  }
function computeNodeBreadths ( ) { var remainingNodes = nodes , nextNodes , x = 0 ; function updateNode ( node ) { node . x = x ; node . dx = nodeWidth ; node . sourceLinks . forEach ( function ( link ) { if ( nextNodes . indexOf ( link . target ) === - 1 ) { nextNodes . push ( link . target ) ; } } ) ; } while ( remainingNodes . length && x < nodes . length ) { nextNodes = [ ] ; remainingNodes . forEach ( updateNode ) ; remainingNodes = nextNodes ; x += 1 ; } if ( rightJustifyEndpoints ) { moveSinksRight ( x - 1 ) ; } if ( ! leftJustifyOrigins ) { moveOriginsRight ( ) ; } scaleNodeBreadths ( ( size [ 0 ] - nodeWidth ) / ( x - 1 ) ) ; }
nodes with no outgoing links are assigned the maximum breadth.
nodes with no outgoing links are assigned the maximum breadth .
// Set x-position and width: // Only add it to the nextNodes list if it is not already present: // Work from left to right. // Keep updating the breadth (x-position) of nodes that are targets of // recently-updated nodes. // Move endpoint nodes all the way to the right? // Let origins appear just before their first target node? // (In this case, we have to do extra work to *not* justify these nodes.) // Apply a scaling factor to the breadths to spread them evenly across the canvas: