chinese_postman 0.1.2 copy "chinese_postman: ^0.1.2" to clipboard
chinese_postman: ^0.1.2 copied to clipboard

outdated

Dart package to solve the Chinese Postman Problem for undirected, weighted graphs

example/chinese_postman_example.dart

import 'package:chinese_postman/chinese_postman.dart';

void main() {
  int start = DateTime.now().millisecondsSinceEpoch;
  Postman p = Postman();

  // Map<int, Map<int, double>> graph = {
  //   1: {2: 70, 3: 70},
  //   2: {5: 50, 6: 50, 1: 70},
  //   3: {4: 60, 5: 70},
  //   4: {5: 80, 8: 100, 9: 90},
  //   5: {8: 40},
  //   6: {7: 40, 8: 60},
  //   7: {8: 40},
  //   8: {9: 70}
  // };
  Map<int, Map<int, double>> graph = {
    1: {2: 6, 5: 10, 4: 10, 3: 10},
    2: {5: 7, 7: 16},
    3: {6: 7, 4: 10},
    4: {6: 5, 5: 1},
    5: {7: 7},
    6: {7: 13},
  };

  List<int> tour = p.postmanTour(graph, startingVertex: 2);
  print(tour);
  print('total cost: ${p.cost()}');
  print(DateTime.now().millisecondsSinceEpoch - start);
}
0
likes
0
points
57
downloads

Publisher

unverified uploader

Weekly Downloads

Dart package to solve the Chinese Postman Problem for undirected, weighted graphs

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dijkstra

More

Packages that depend on chinese_postman