title: In D3 force-directed layout, how can I position fixed nodes programmatically, without dragging?
body: <p>In the answer to <a href="https://stackoverflow.com/questions/10392505/fix-node-position-in-d3-force-directed-layout">this question</a>, mbostock notes that "if a node is fixed, it can only be moved by dragging and not by the simulation."</p>
  
  <p>What if I'd like to position the nodes programmatically, however, perhaps by setting the d.x and d.y values? My attempts thus far have failed. I have tried the obvious setting of d.x and d.y, but these values are ignored for fixed nodes. I've also attempted to temporarily "un-fix", redraw, then "re-fix" the nodes, but this also doesn't work -- the nodes are magically reset to their original positions on the next tick.</p>
  
  <p>Here's a <a href="http://jsfiddle.net/2ov2La89/8/" rel="nofollow noreferrer">running example</a> of this latter approach.</p>
  
  <p>Here's the key bit of that code, executed on click:</p>
  
  <pre><code>function explicitlyPosition() {
    node.each(function(d) {
      d.x = 0;
      d.y = 0;
      d.fixed = false;
    });
    tick();
    node.each(function(d) {
      d.fixed = true;
    });
    force.resume();
  }
  </code></pre>
  
  <p>Is there a way to do this using the approach I've tried or one similar? Or I could use a totally different graph layout in D3, but I would ideally like large portions of my graph to be laid out in a force-directed manner.</p>
  
  <p>Thanks!</p>