0

I tried to draw a graph in circle layout.I have given the x and y position for the nodes as follows X=Math.cos(Math.PI*(u)/l)*R

Y=Math.sin(Math.PI*(u)/l)*R

where u is an incrementor and l is number of nodes and R is radius. the equation seems to be correct.Problem is the graph is tilted to left side.

For a simple graph also(for two nodes) edge is not in the horizontal position, I think the position of x and y is changed in some other function call(sigma libraries)

Can anyone help me in this regard

2 Answers2

2

In the animate.html example into sigma.js, there is an example of 'circle graph'.

And the correct formula is :

circular_x: L * Math.cos(Math.PI * 2 * i / N ),
circular_y: L * Math.sin(Math.PI * 2 * i / N ),

Where

  • L : is the
  • radius i : the index N : the numbe
  • r of node

If I use this code, and I generate a graph of two node, edge is horizontal.

I used sigma v1.0.3

logisima
  • 7,340
  • 1
  • 18
  • 31
0

I encountered a similar issue, but @logisima answer didn't solve mine.

Sometimes, this issue could be a result of the node key. A Graph Nodes are expected to have unique keys.

Make sure your keys are unique

const allNodes = [{
  key: '1' // UNIQUE,
  name: 'anyname 1',
  label: 'LABEL1',
  x: Math.random() * 2 // LENGTH OF ALL NODES,
  y: Math.random() * 2 // LENGTH OF ALL NODES,
},
{
  key: '2' // UNIQUE,
  name: 'anyname 1',
  label: 'LABEL1',
  x: Math.random() * 2 // LENGTH OF ALL NODES,
  y: Math.random() * 2 // LENGTH OF ALL NODES,
}]
Akolade Adesanmi
  • 1,152
  • 11
  • 15