title: Running ForceAtlas2 from a set position in Sigma.js
body: <p>I am trying to render a complex network using the React-Sigma wrapper. I know the base structure of this network to be many nodes of degree one and some of a very high degree. To this end, I have preformatted my graph data with x and y coordinates that represent an approximate layout, with degree one nodes clustered around the nodes they are connected to. I then want to run the ForceAtlas2 simulation <em>from this point</em>. However, when I try to do this, the simulation appears to just randomise and change the initial positions of the nodes to be in the centre, as seen in this gif:</p>
  <p><a href="https://i.stack.imgur.com/EWzT2.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EWzT2.gif" alt="Node animation" /></a></p>
  <p>Is there any way to stop this from happening and run the simulation from the initial positions? My code is below:</p>
  <pre><code>const App = () =&gt; {
      const myGraph = getExampleGraph();
      return (
          &lt;Sigma
              graph={myGraph}
              renderer=&quot;webgl&quot;
              settings={{
                  clone: false,
                  batchEdgesDrawing: true,
              }}
              style={{
                  height: &quot;100vh&quot;
              }}
          &gt;
              &lt;ForceAtlas2
                  iterationsPerRender={1}
                  barnesHutOptimize
                  barnesHutTheta={1}
                  timeout={50000}
                  worker
              /&gt;
          &lt;/Sigma&gt;
      )
  }
  
  </code></pre>
  <p>Code to get a random example graph like the one I described:</p>
  <pre><code>export const getRandomInt = (max: number) =&gt; Math.floor(Math.random() * Math.floor(max));
  
  export const getRandomPosition = () =&gt; ({
      x: Math.random(),
      y: Math.random()
  });
  
  export const randomisePosition = (position) =&gt; ({
      x: position.x + (Math.random() - .5)/10,
      y: position.y + (Math.random() - .5)/10
  });
  
  
  export const getExampleGraph = () =&gt; {
  
      const positions: any = {
          &quot;1&quot;: getRandomPosition(),
          &quot;2&quot;: getRandomPosition(),
          &quot;3&quot;: getRandomPosition()
      };
      const highDegNodes = [
          { id: &quot;1&quot;, size: 20, label: &quot;1&quot;, ...positions[&quot;1&quot;]},
          { id: &quot;2&quot;, size: 20, label: &quot;2&quot;, ...positions[&quot;2&quot;] },
          { id: &quot;3&quot;, size: 20, label: &quot;3&quot;, ...positions[&quot;3&quot;] }
      ];
      const nodes = Object.assign([], highDegNodes);
      const edges = [];
  
      for(let i = 0; i &lt; 50; i += 1) {
          const id = (i + 4) + '';
          const node = { id, size: 1, label: id, x: 0, y: 0 };
  
          const target = (getRandomInt(3) + 1) + '';
          edges.push({
              id: `${id}:${target}:${i}`,
              source: id,
              target,
          });
  
          const nodePos = randomisePosition(positions[target]);
          node.x = nodePos.x;
          node.y = nodePos.y;
          nodes.push(node);
  
          if (Math.random() &lt; .1) {
              const target2 = (getRandomInt(3) + 1) + '';
              edges.push({
                  id: `${id}:${target2}:${i}:2`,
                  source: id,
                  target: target2,
              });
          }
      }
  
      return {
          nodes,
          edges
      }
  };
  </code></pre>