1 unstable release

Uses old Rust 2015

0.1.0 May 18, 2017

#9 in #tsp

46 downloads per month

MIT/Apache

19KB
487 lines

tsplib

Parser for TSPLIB instances.

Build Status

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Parser for TSPLIB instances.

Example

use tsplib::{EdgeWeightType, NodeCoord, Type};
use std::io::Cursor;

let data = br#"
NAME : example
COMMENT : this is
COMMENT : a simple example
TYPE : TSP
DIMENSION : 3
EDGE_WEIGHT_TYPE: EUC_2D
NODE_COORD_SECTION
  1 1.2 3.4
  2 5.6 7.8
  3 9.0 1.2
EOF
"#;

let instance = tsplib::parse(Cursor::new(&data[..])).unwrap();
assert_eq!("example", instance.name);
assert_eq!(Some(Type::Tsp), instance.type_);
assert_eq!(vec!["this is".to_owned(), "a simple example".to_owned()], instance.comment);
assert_eq!(3, instance.dimension);
assert_eq!(0, instance.capacity);
assert_eq!(None, instance.edge_data);
assert_eq!(None, instance.edge_weight);
assert_eq!(Some(EdgeWeightType::Euc2d), instance.edge_weight_type);
assert_eq!(None, instance.fixed_edges);
assert_eq!(Some(NodeCoord::Two(vec![(1, 1.2, 3.4),
                                    (2, 5.6, 7.8),
                                    (3, 9.0, 1.2)])),
           instance.node_coord);
assert_eq!(None, instance.display_data);
assert_eq!(None, instance.display_data_type);
assert_eq!(None, instance.tour);

No runtime deps