Search code examples
javascriptsigma.jssigma-grid-control

Not able to fix x and y position in sigma js


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


Solution

  • 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