Skip to content

Commit

Permalink
Merge pull request #104 from nabil6391/testing-sugiyama
Browse files Browse the repository at this point in the history
Improve layout algorithm to resolve node overlaps for Sugiyama
  • Loading branch information
nabil6391 committed Apr 29, 2023
2 parents f1ac307 + 27fe573 commit 5bc24f6
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 72 deletions.
102 changes: 101 additions & 1 deletion example/lib/layer_graphview_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,109 @@ class LayerGraphPageFromJson extends StatefulWidget {
}

class _LayerGraphPageFromJsonState extends State<LayerGraphPageFromJson> {
var json = {"edges":[{"from":"7045321","to":"308264215"},{"from":"308264215","to":"205893853"},{"from":"205893853","to":"673966248"},{"from":"673966248","to":"358204164"},{"from":"358204164","to":"215888392"},{"from":"215888392","to":"403621992"},{"from":"215888392","to":"777909510"},{"from":"777909510","to":"100213815"},{"from":"100213815","to":"499504374"},{"from":"499504374","to":"855703404"},{"from":"499504374","to":"991104907"},{"from":"991104907","to":"374555325"},{"from":"991104907","to":"58236163"},{"from":"991104907","to":"1051662797"},{"from":"1051662797","to":"523457656"},{"from":"1051662797","to":"178236248"},{"from":"178236248","to":"403818044"},{"from":"403818044","to":"633692579"},{"from":"403818044","to":"326876433"},{"from":"178236248","to":"294992198"},{"from":"178236248","to":"207728643"},{"from":"207728643","to":"474861525"},{"from":"207728643","to":"704015142"},{"from":"704015142","to":"891912594"},{"from":"704015142","to":"93790829"},{"from":"704015142","to":"713878610"},{"from":"704015142","to":"568109301"},{"from":"100213815","to":"298138012"},{"from":"298138012","to":"1051662797"},{"from":"777909510","to":"344277619"},{"from":"344277619","to":"311541390"},{"from":"311541390","to":"761787449"},{"from":"761787449","to":"30973213"},{"from":"30973213","to":"523457656"},{"from":"30973213","to":"178236248"},{"from":"761787449","to":"259733602"},{"from":"311541390","to":"128821445"},{"from":"344277619","to":"1003131136"},{"from":"1003131136","to":"130000569"},{"from":"1003131136","to":"319536467"},{"from":"319536467","to":"299942125"},{"from":"299942125","to":"178926206"},{"from":"299942125","to":"675835322"},{"from":"299942125","to":"1000135767"},{"from":"319536467","to":"483940059"},{"from":"483940059","to":"497866879"},{"from":"483940059","to":"606660618"},{"from":"483940059","to":"841482899"},{"from":"358204164","to":"963021319"},{"from":"963021319","to":"130000569"},{"from":"963021319","to":"319536467"},{"from":"358204164","to":"803634418"},{"from":"803634418","to":"142291521"},{"from":"142291521","to":"525361131"},{"from":"525361131","to":"422007713"},{"from":"422007713","to":"184596308"},{"from":"422007713","to":"1020140270"},{"from":"422007713","to":"779910731"},{"from":"525361131","to":"859310299"},{"from":"859310299","to":"514613187"},{"from":"514613187","to":"680752017"},{"from":"680752017","to":"1058283666"},{"from":"680752017","to":"887688252"},{"from":"680752017","to":"717256682"},{"from":"717256682","to":"409719617"},{"from":"409719617","to":"1014464856"},{"from":"1014464856","to":"773448863"},{"from":"773448863","to":"988347957"},{"from":"773448863","to":"152738454"},{"from":"773448863","to":"338899146"},{"from":"1014464856","to":"629986173"},{"from":"629986173","to":"773448863"},{"from":"629986173","to":"835742723"},{"from":"1014464856","to":"835742723"},{"from":"409719617","to":"81570852"},{"from":"717256682","to":"136164004"},{"from":"136164004","to":"852978894"},{"from":"852978894","to":"344862780"},{"from":"344862780","to":"1001389664"},{"from":"1001389664","to":"404010795"},{"from":"1001389664","to":"644174136"},{"from":"644174136","to":"979597620"},{"from":"979597620","to":"267068484"},{"from":"979597620","to":"660658782"},{"from":"644174136","to":"1041729484"},{"from":"1041729484","to":"184754595"},{"from":"184754595","to":"564383463"},{"from":"564383463","to":"328736689"},{"from":"564383463","to":"371898357"},{"from":"371898357","to":"1035929373"},{"from":"1035929373","to":"619697312"},{"from":"619697312","to":"64229994"},{"from":"619697312","to":"865071585"},{"from":"619697312","to":"834626072"},{"from":"1035929373","to":"201892784"},{"from":"201892784","to":"160374239"},{"from":"201892784","to":"925759772"},{"from":"371898357","to":"601412432"},{"from":"184754595","to":"371898357"},{"from":"1041729484","to":"371898357"},{"from":"344862780","to":"409719617"},{"from":"852978894","to":"63704729"},{"from":"136164004","to":"293710340"},{"from":"514613187","to":"136164004"},{"from":"859310299","to":"81570852"},{"from":"859310299","to":"1014464856"},{"from":"142291521","to":"985700044"},{"from":"142291521","to":"756415350"},{"from":"803634418","to":"420237319"},{"from":"420237319","to":"450548638"},{"from":"420237319","to":"210548489"},{"from":"210548489","to":"809729654"},{"from":"210548489","to":"736196011"},{"from":"736196011","to":"763132131"},{"from":"763132131","to":"139733908"},{"from":"139733908","to":"141077435"},{"from":"139733908","to":"601580192"},{"from":"601580192","to":"29466216"},{"from":"601580192","to":"530702767"},{"from":"530702767","to":"1181832"},{"from":"530702767","to":"514613187"},{"from":"530702767","to":"1014464856"},{"from":"139733908","to":"530702767"},{"from":"763132131","to":"805599981"},{"from":"805599981","to":"596402985"},{"from":"805599981","to":"207631270"},{"from":"207631270","to":"528636695"},{"from":"207631270","to":"142291521"},{"from":"805599981","to":"148019367"},{"from":"148019367","to":"894038421"},{"from":"148019367","to":"544426319"},{"from":"148019367","to":"878212306"},{"from":"878212306","to":"94541671"},{"from":"878212306","to":"1007715424"},{"from":"1007715424","to":"258386700"},{"from":"1007715424","to":"546819439"},{"from":"546819439","to":"836825089"},{"from":"836825089","to":"16287329"},{"from":"836825089","to":"256254716"},{"from":"256254716","to":"631230382"},{"from":"631230382","to":"900886483"},{"from":"631230382","to":"133436503"},{"from":"256254716","to":"751624200"},{"from":"836825089","to":"716757473"},{"from":"546819439","to":"470041669"},{"from":"546819439","to":"180888016"},{"from":"736196011","to":"901547914"},{"from":"901547914","to":"425184961"},{"from":"425184961","to":"760673978"},{"from":"760673978","to":"825228914"},{"from":"760673978","to":"530702767"},{"from":"425184961","to":"955125232"},{"from":"955125232","to":"167653392"},{"from":"955125232","to":"530702767"},{"from":"901547914","to":"530702767"},{"from":"210548489","to":"640144001"},{"from":"640144001","to":"135966238"},{"from":"640144001","to":"959156288"},{"from":"803634418","to":"358204164"},{"from":"673966248","to":"803634418"},{"from":"308264215","to":"1039602752"},{"from":"1039602752","to":"673966248"}]
var json = {
"edges": [
{"from": "651372822", "to": "780273411"},
{"from": "780273411", "to": "347969226"},
{"from": "347969226", "to": "157648240"},
{"from": "157648240", "to": "676569359"},
{"from": "676569359", "to": "91606809"},
{"from": "676569359", "to": "154477528"},
{"from": "676569359", "to": "843017499"},
{"from": "843017499", "to": "983981562"},
{"from": "843017499", "to": "504040588"},
{"from": "504040588", "to": "446062329"},
{"from": "446062329", "to": "622974985"},
{"from": "622974985", "to": "1044667060"},
{"from": "622974985", "to": "556331086"},
{"from": "556331086", "to": "995470137"},
{"from": "995470137", "to": "1056219149"},
{"from": "1056219149", "to": "239427950"},
{"from": "995470137", "to": "239427950"},
{"from": "995470137", "to": "175942639"},
{"from": "175942639", "to": "239427950"},
{"from": "995470137", "to": "914018177"},
{"from": "914018177", "to": "239427950"},
{"from": "556331086", "to": "776412718"},
{"from": "776412718", "to": "311423239"},
{"from": "311423239", "to": "71054174"},
{"from": "71054174", "to": "436868910"},
{"from": "436868910", "to": "86163114"},
{"from": "86163114", "to": "876219077"},
{"from": "436868910", "to": "385178969"},
{"from": "385178969", "to": "18115125"},
{"from": "71054174", "to": "869070735"},
{"from": "776412718", "to": "71054174"},
{"from": "776412718", "to": "978694637"},
{"from": "978694637", "to": "71054174"},
{"from": "776412718", "to": "481786088"},
{"from": "481786088", "to": "71054174"},
{"from": "622974985", "to": "657744632"},
{"from": "657744632", "to": "995470137"},
{"from": "657744632", "to": "776412718"},
{"from": "622974985", "to": "398317434"},
{"from": "843017499", "to": "441827615"},
{"from": "843017499", "to": "345074369"},
{"from": "345074369", "to": "983981562"},
{"from": "345074369", "to": "504040588"},
{"from": "345074369", "to": "441827615"},
{"from": "843017499", "to": "1038969179"},
{"from": "1038969179", "to": "983981562"},
{"from": "1038969179", "to": "504040588"},
{"from": "1038969179", "to": "441827615"},
{"from": "1038969179", "to": "345074369"},
{"from": "676569359", "to": "582216004"},
{"from": "582216004", "to": "983981562"},
{"from": "582216004", "to": "853366903"},
{"from": "853366903", "to": "549040211"},
{"from": "549040211", "to": "438987595"},
{"from": "438987595", "to": "1044667060"},
{"from": "438987595", "to": "927647245"},
{"from": "927647245", "to": "995470137"},
{"from": "927647245", "to": "286211157"},
{"from": "286211157", "to": "466182692"},
{"from": "466182692", "to": "724424756"},
{"from": "724424756", "to": "739317534"},
{"from": "739317534", "to": "315526883"},
{"from": "724424756", "to": "869070735"},
{"from": "286211157", "to": "724424756"},
{"from": "286211157", "to": "175042175"},
{"from": "175042175", "to": "724424756"},
{"from": "286211157", "to": "567113513"},
{"from": "567113513", "to": "724424756"},
{"from": "438987595", "to": "625227999"},
{"from": "625227999", "to": "995470137"},
{"from": "625227999", "to": "286211157"},
{"from": "438987595", "to": "398317434"},
{"from": "582216004", "to": "441827615"},
{"from": "582216004", "to": "306330186"},
{"from": "306330186", "to": "983981562"},
{"from": "306330186", "to": "853366903"},
{"from": "306330186", "to": "441827615"},
{"from": "582216004", "to": "476307185"},
{"from": "476307185", "to": "983981562"},
{"from": "476307185", "to": "853366903"},
{"from": "476307185", "to": "441827615"},
{"from": "157648240", "to": "1031140514"},
{"from": "1031140514", "to": "983981562"},
{"from": "1031140514", "to": "329379632"},
{"from": "1031140514", "to": "441827615"},
{"from": "1031140514", "to": "722519336"},
{"from": "722519336", "to": "983981562"},
{"from": "722519336", "to": "329379632"},
{"from": "722519336", "to": "441827615"},
{"from": "722519336", "to": "431136131"},
{"from": "431136131", "to": "329379632"},
{"from": "1031140514", "to": "431136131"},
{"from": "347969226", "to": "91606809"},
{"from": "347969226", "to": "154477528"},
{"from": "347969226", "to": "843017499"},
{"from": "347969226", "to": "582216004"},
{"from": "780273411", "to": "383221931"}
],
};


@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
sdk: flutter
graphview:
path: ../
provider: ^4.3.2+2
provider: ^6.0.3

dev_dependencies:
flutter_test:
Expand Down
4 changes: 4 additions & 0 deletions lib/Graph.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
part of graphview;

extension on Node {
Rect toRect() => Rect.fromLTRB(x, y, x + width, y + height);
}

class Graph {
final List<Node> _nodes = [];
final List<Edge> _edges = [];
Expand Down
Loading

0 comments on commit 5bc24f6

Please sign in to comment.