diff --git a/example/pubspec.lock b/example/pubspec.lock index 91e8d9b..ed0ff0e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.0" charcode: dependency: transitive description: @@ -66,14 +66,14 @@ packages: path: ".." relative: true source: path - version: "1.1.0" + version: "1.1.1" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.10" meta: dependency: transitive description: @@ -148,7 +148,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.2" typed_data: dependency: transitive description: @@ -162,7 +162,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.17.0" diff --git a/pubspec.lock b/pubspec.lock index c2948fd..068ff17 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -21,7 +21,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.0" charcode: dependency: transitive description: @@ -66,7 +66,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" + version: "0.12.10" meta: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.2" typed_data: dependency: transitive description: @@ -141,7 +141,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" sdks: - dart: ">=2.14.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.17.0" diff --git a/test/example_trees.dart b/test/example_trees.dart new file mode 100644 index 0000000..6f33777 --- /dev/null +++ b/test/example_trees.dart @@ -0,0 +1,437 @@ +const exampleTreeWith140Nodes = { + "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"} + ] +}; + +final exampleTrees = >[ + { + "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"} + ] + }, + { + "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"} + ], + }, + exampleTreeWith140Nodes, +]; diff --git a/test/sugiyama_algorithm_test.dart b/test/sugiyama_algorithm_test.dart index 45ada65..b5f181d 100644 --- a/test/sugiyama_algorithm_test.dart +++ b/test/sugiyama_algorithm_test.dart @@ -4,9 +4,26 @@ import 'package:flutter/material.dart'; import 'package:graphview/GraphView.dart'; import 'package:flutter_test/flutter_test.dart'; +import 'example_trees.dart'; + const itemHeight = 100.0; const itemWidth = 100.0; +extension on Graph { + void inflateWithJson(Map json) { + var edges = json['edges']! as List; + edges.forEach((element) { + var fromNodeId = element['from']; + var toNodeId = element['to']; + addEdge(Node.Id(fromNodeId), Node.Id(toNodeId)); + }); + } +} + +extension on Node { + Rect toRect() => Rect.fromLTRB(x, y, x + width, y + height); +} + void main() { group('Sugiyama Graph', () { final graph = Graph(); @@ -228,11 +245,9 @@ void main() { }); test('Sugiyama for a complex graph with 140 nodes', () { + final json = exampleTreeWith140Nodes; - 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"}] - }; - - final graph = Graph(); + final graph = Graph(); var edges = json['edges']!; edges.forEach((element) { @@ -246,9 +261,9 @@ void main() { ..levelSeparation = 15 ..orientation = SugiyamaConfiguration.ORIENTATION_LEFT_RIGHT; - var algorithm = SugiyamaAlgorithm(_configuration); + final algorithm = SugiyamaAlgorithm(_configuration); - for(var i = 0 ; i < graph.nodeCount(); i++ ) { + for (var i = 0; i < graph.nodeCount(); i++) { graph.getNodeAtPosition(i).size = Size(itemWidth, itemHeight); } @@ -269,13 +284,38 @@ void main() { expect(graph.getNodeAtPosition(122).position, Offset(1850.0, 3252.5)); }); + test("Sugiyama child nodes never overlaps", () { + for (final json in exampleTrees) { + final graph = Graph()..inflateWithJson(json); + for (var i = 0; i < graph.nodeCount(); i++) { + graph.getNodeAtPosition(i).size = Size(itemWidth, itemHeight); + } + + SugiyamaAlgorithm(SugiyamaConfiguration())..run(graph, 10, 10); + + for (var i = 0; i < graph.nodeCount(); i++) { + final currentNode = graph.getNodeAtPosition(i); + for (var j = 0; j < graph.nodeCount(); j++) { + final otherNode = graph.getNodeAtPosition(j); + + if (currentNode.key == otherNode.key) continue; + final currentRect = currentNode.toRect(); + final otherRect = otherNode.toRect(); + + final overlaps = currentRect.overlaps(otherRect); + expect(false, overlaps); + } + } + } + }); + test('Sugiyama Performance for 100 nodes to be less than 2.5s', () { - final graph = Graph(); + final graph = Graph(); - int rows = 100; + var rows = 100; - for(int i = 1; i <= rows; i++) { - for(int j = 1; j <= i; j++) { + for (var i = 1; i <= rows; i++) { + for (var j = 1; j <= i; j++) { graph.addEdge(Node.Id(i), Node.Id(j)); } } @@ -285,9 +325,9 @@ void main() { ..levelSeparation = 15 ..orientation = SugiyamaConfiguration.ORIENTATION_LEFT_RIGHT; - var algorithm = SugiyamaAlgorithm(_configuration); + var algorithm = SugiyamaAlgorithm(_configuration); - for(var i = 0 ; i < graph.nodeCount(); i++ ) { + for (var i = 0; i < graph.nodeCount(); i++) { graph.getNodeAtPosition(i).size = Size(itemWidth, itemHeight); }