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

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() {

  Postman p = Postman();

  // Repeating entries in the graph will not add duplicate edges.
  // If the original graph contains duplicate edges,
  // add new vertices with a distance of 0 from other vertices.

  Map<int, Map<int, double>> graph = {
    1: {2: 6, 5: 10, 4: 10, 3: 10},
    2: {5: 7, 7: 16},
    3: {4: 10, 6: 7},
    4: {5: 1, 6: 5},
    5: {7: 7},
    6: {7: 13},
    //This will not change the result
    //since the edges are already above
    // 7: {2: 16, 5: 7, 6: 13}
  };

  List<int> tour = p.postmanTour(graph, startingVertex: 2);

  print(tour);
  print('total cost: ${p.cost()}');
}
0
likes
125
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

Documentation

API reference

License

BSD-3-Clause, MIT (license)

Dependencies

dijkstra

More

Packages that depend on chinese_postman