Crate tsplib [] [src]

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);

Structs

Instance

An TSPLIB instance.

Enums

DisplayDataType
EdgeData
EdgeWeight
EdgeWeightType
NodeCoord
Type

Type of the instance.

Functions

parse

Read a TSPLIB instance from reader.

read

Read a TSPLIB instance from path.