Sigma.js展示与ForceAtlas2

huangapple go评论121阅读模式
英文:

Sigma.js demo with ForceAtlas2

问题

我需要与ForceAtlas2布局完全相同的sigma.js演示,这意味着提供一个dataset.json,而不指定每个节点的x/y坐标,有人完成了这个吗?我能找到一个这样做的示例吗?

英文:

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

得分: 0

我已经实现了一个没有指定节点的xy坐标的ForceAtlas2布局。
基本上,如果您需要使用任何布局,则需要像这样初始化以下属性:

const graph = new DirectedGraph();

// 初始化x和y坐标,节点和边的大小
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);
});

这将创建一些重要的属性,否则您的图形将无法生成。
在完成这些操作后,您可以使用任何想要的布局。如果您有任何问题,请告诉我。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月29日 22:25:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76358157.html
  • sigma.js
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定