nabil6391 / graphview

Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
MIT License
420 stars 114 forks source link

Sugiyama algorithm node placements issues: steep edge angles #68

Open louisdeveseleer opened 2 years ago

louisdeveseleer commented 2 years ago

Hi, thank you for making this package, it's great and is the only that does what I need. I'm using the Sugiyama graph and some parts of it look great (first image), while other parts look weird (second image), with all the edges going at a steep angle, which is not visually pleasing. Am I doing something wrong, or is there a way to improve the algorithm?

Also, is it possible to tell the algorithm at which level should each node be placed? In my case, it's a skill tree of fitness exercises, and I have a difficulty property for each of them, so it'd be nice if each graph level corresponds to one difficulty level.

Screenshot_1642340399 Screenshot_1642340411

nabil6391 commented 2 years ago

Hi, Would it be possible to export the graph, there is an option graph.toJsonString() to export the nodes.

Sugiyama adjusts the levels on their own, so we dont have option to change it. Have you tried using BuchheimWalker Algorithm

louisdeveseleer commented 2 years ago

Sure, here is the output from graph.toJson():

{"nodes":["861143648","363149111","425016743","46502864","550884169","426397323","518506963","398168494","997689484","851406927","713254003","14702141","93133676","657382005","1001948622","795722572","766962098","209335516","246132442","1047486799","209106128","729343021","114815814","762868910","704573413","440451515","952863560","691189756","261535952","1067616807","557033177","991971981","251785856","524601950","1035736348","525148941","410719830","264275168","339021019","800028955","675668189","1008557465","242462028","25487232","455725073","316258101","207956277","436749410","498737363","760310820","713385334","122745625","700594463","1012781785","1054578839","433831606","701227482","136897695","93919295","862319578","487235213","511710951"],"edges":[{"from":"861143648","to":"363149111"},{"from":"425016743","to":"46502864"},{"from":"861143648","to":"425016743"},{"from":"550884169","to":"426397323"},{"from":"550884169","to":"518506963"},{"from":"398168494","to":"550884169"},{"from":"997689484","to":"851406927"},{"from":"997689484","to":"713254003"},{"from":"997689484","to":"14702141"},{"from":"997689484","to":"93133676"},{"from":"657382005","to":"997689484"},{"from":"1001948622","to":"997689484"},{"from":"795722572","to":"766962098"},{"from":"209335516","to":"795722572"},{"from":"246132442","to":"1047486799"},{"from":"426397323","to":"246132442"},{"from":"209106128","to":"729343021"},{"from":"114815814","to":"729343021"},{"from":"762868910","to":"114815814"},{"from":"704573413","to":"440451515"},{"from":"440451515","to":"952863560"},{"from":"691189756","to":"440451515"},{"from":"261535952","to":"691189756"},{"from":"1067616807","to":"557033177"},{"from":"1067616807","to":"991971981"},{"from":"657382005","to":"251785856"},{"from":"524601950","to":"657382005"},{"from":"1035736348","to":"525148941"},{"from":"410719830","to":"525148941"},{"from":"264275168","to":"525148941"},{"from":"339021019","to":"800028955"},{"from":"339021019","to":"675668189"},{"from":"339021019","to":"1047486799"},{"from":"1008557465","to":"242462028"},{"from":"25487232","to":"455725073"},{"from":"93133676","to":"316258101"},{"from":"762868910","to":"455725073"},{"from":"207956277","to":"1008557465"},{"from":"436749410","to":"498737363"},{"from":"760310820","to":"713385334"},{"from":"122745625","to":"700594463"},{"from":"1012781785","to":"455725073"},{"from":"700594463","to":"1054578839"},{"from":"433831606","to":"557033177"},{"from":"701227482","to":"557033177"},{"from":"136897695","to":"93919295"},{"from":"991971981","to":"93919295"},{"from":"862319578","to":"487235213"},{"from":"991971981","to":"136897695"},{"from":"1012781785","to":"511710951"}]}

I tried BuchheimWalker but it only displayed a few nodes so there seemed to be something wrong (maybe with what I did).

nabil6391 commented 2 years ago

Thanks, I still dont have much time, but I will try to look into it