USCA                   package:TSP                   R Documentation

_U_S_C_A_3_1_2/_U_S_C_A_5_0 - _3_1_2/_5_0 _c_i_t_i_e_s _i_n _t_h_e _U_S _a_n_d _C_a_n_a_d_a

_D_e_s_c_r_i_p_t_i_o_n:

     The 'USCA312' dataset contains the distances between 312 cities in
     the US and Canada as an object of class 'TSP'.  'USCA50' is a
     subset of 'USCA312' containing only the first 50 cities.

     The 'USCA312_map' dataset contains  spatial data of the 312
     cities.

_U_s_a_g_e:

     data("USCA312")
     data("USCA312_map")
     data("USCA50")

_F_o_r_m_a_t:

     'USCA312' and 'USCA50' are objects of class 'TSP'. 'USCA312_map'
     contains in 'USCA312_coords' the spatial coordinates of the 312
     cities and in 'USCA312_basemap' a part of the  map of North
     America.

_D_e_t_a_i_l_s:

     For 'USCA312_map' several packages for geographic data are needed
     (see Examples section).

     We want to thank Roger Bivand for his help with plotting the map.

_S_o_u_r_c_e:

     John Burkardt, CITIES - City Distance Datasets,  <URL:
     http://www.csit.fsu.edu/~burkardt/datasets/cities/cities.html>

_E_x_a_m_p_l_e_s:

     data("USCA312")
     data("USCA312_map")

     ## calculate a tour
     tour <- solve_TSP(USCA312)
     tour

     ## load map tools
     library("maps")
     library("sp")
     library("maptools")

     ## plot map
     plot(as(USCA312_coords, "Spatial"), axes=TRUE)
     plot(USCA312_basemap, add=TRUE, col = "gray")

     ## plot tour and add cities
     tour_line <- SpatialLines(list(Lines(list(
         Line(USCA312_coords[c(tour, tour[1]),])))))
     plot(tour_line, add=TRUE, col = "red")
     points(USCA312_coords, pch=3, cex=0.4, col="black")

