vasturiano / force-graph

Force-directed graph rendered on HTML5 canvas
https://vasturiano.github.io/force-graph/example/directional-links-particles/
MIT License
1.56k stars 248 forks source link

Ring network link error #113

Open nathak opened 4 years ago

nathak commented 4 years ago

Problem Test Data

const data= {
  nodes : [
    {id : '1'},
    {id : '2'},
    {id : '3'},
    {id : '4'},
    {id : '5'},
    {id : '6'},
    {id : '7'},
    {id : '8'},
  ],
  links : [
    {source : '1', target : '2' , color : '#fff'},
    {source : '2', target : '3' , color : '#fff'},
    {source : '3', target : '4' , color : '#fff'},
    {source : '4', target : '5' , color : '#fff'},
    {source : '5', target : '6' , color : '#fff'},
    {source : '6', target : '7' , color : '#fff'},
    {source : '7', target : '8' , color : '#fff'},
    {source : '8', target : '1' , color : '#fff'},
  ]
};

[console] error] Uncaught Invalid DAG structure Found cycle in node path: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7-> 8 -> 1

I get an error. Is the data a problem?

vasturiano commented 4 years ago

@nathak thanks for reaching out.

As mentioned in the docs, dagMode (Directed Acyclic Graph) only works if your data has no loops. So yes, if you want to plot your data using the DAG layout constraint, make sure to remove the cycle in it.

nathak commented 4 years ago

@vasturiano thank you for answer.

Doesn't it support layout that supports ring network?

vasturiano commented 4 years ago

You can just disable the dagMode and let the force-directed engine do its work. Like in this example: https://vasturiano.github.io/force-graph/example/curved-links/