diff --git a/.gitignore b/.gitignore index 3c8a157..47418c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Files and directories created by pub. .dart_tool/ .packages +*.txt # Conventional directory for build output. build/ diff --git a/bin/main.dart b/bin/main.dart index 0eacfe0..dc0f328 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -1,7 +1,7 @@ import 'src/graph.dart'; void main(List arguments) { - Map x = {1: 10, 2: 20}; + Map x = {1: 10, 2: 11}; var p = Dot.fromMap("Т1", x); p.printD(); x = {}; diff --git a/bin/src/graph.dart b/bin/src/graph.dart index 626c870..1d578ff 100644 --- a/bin/src/graph.dart +++ b/bin/src/graph.dart @@ -3,8 +3,9 @@ import 'dart:io'; class Separators { final String dotToConnections = ": "; final String dotToLength = "|"; - final String hasLength = "Вес\n"; - final String hasNoLength = "НетВеса\n"; + final String space = " "; + final String hasLength = "Взвешенный\n"; + final String hasNoLength = "НеВзвешенный\n"; final String isOriented = "Ориентированный\n"; final String isNotOriented = "НеОриентированный\n"; final String nL = "\n"; @@ -289,19 +290,34 @@ class Graphs { _amount = _dots.length; _oriented = oriented; _syncNum(); - if (!_oriented) { - for (int i = 0; i < _amount; i++) { - _fixPathAfterInsert(_dots[i]); - } - } if (!_oriented) _fullFix(); } Graphs.fromFile(String path) { + Separators sep = Separators(); File file = File(path); List lines = file.readAsLinesSync(); + _name = lines.removeAt(0); + _oriented = lines.removeAt(0) == sep.isOriented; + _useLength = lines.removeAt(0) == sep.hasLength; + _dots = []; for (var l in lines) { - print(l); + if (l != sep.end) { + var spl = l.split(sep.space); + List dot = []; + List len = []; + String name = spl.removeAt(0); + name = name.substring(0, name.length - 1); + for (var splitted in spl) { + var dt = splitted.split(sep.dotToLength); + dot.add(int.parse(dt[0])); + len.add(int.parse(dt[1])); + } + Dot add = Dot.fromTwoLists(name, dot, len); + _dots.add(add); + } } + _syncNameTable(); + if (!_oriented) _fullFix(); } //*******Constructor******** diff --git a/pubspec.lock b/pubspec.lock index 06a8eb1..3e4a837 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,4 +9,4 @@ packages: source: hosted version: "1.0.1" sdks: - dart: ">=2.15.0-178.0.dev <3.0.0" + dart: ">=2.14.0-178.0.dev <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 68d13da..0a081b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # homepage: https://www.example.com environment: - sdk: '>=2.15.0-178.0.dev <3.0.0' + sdk: '>=2.14.0-178.0.dev <3.0.0' # dependencies: