Sigma.js demo with ForceAtlas2

171 views Asked by At

I need the exact demo of sigma.js just with ForceAtlas2 layout - meaning providing a dataset.json without specifying x/y coordinates per node, has anyone accomplished that? can I find an example that does that?

1

There are 1 answers

0
wthrajat On BEST ANSWER

I have implemented a ForceAtlas2 layout without specifying x and y coordinates for nodes. Basically if you need to use any layout; you need to initialize the following attributes like this:

  
  const graph = new DirectedGraph();

 // Initialise x and y coordinates; nodes and edges size
  let i = 0;
  graph.forEachNode((node) => {
    graph.setNodeAttribute(node, "x", i++);
    graph.setNodeAttribute(node, "y", i);
    i++;
  });
  graph.forEachNode((node) => {
    graph.setNodeAttribute(node, "size", 7);
  });
  graph.forEachEdge((edge) => {
    graph.setEdgeAttribute(edge, "size", 1);
  });

This creates some important attributes without which your graph will not be generated. After doing this, you can use any layout you want. Let me know if you have any quesions.