#*****************************************************************************80 # ## tsp_dantzig42_graph() plots a traveling salesman tour. # # Discussion: # # This code uses the Rgraphviz package. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 26 July 2026 # # Author: # # John Burkardt # cat ( "\n" ) cat ( "tsp_dantzig42_graph():\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Plot a traveling salesman route as a graph.\n" ) source ( "/home/john/public_html/r_src/tsp_dantzig42/tsp_dantzig42_order.R" ) source ( "/home/john/public_html/r_src/tsp_dantzig42/tsp_dantzig42_xy.R" ) n <- 42 order <- tsp_dantzig42_order ( ) xy <- tsp_dantzig42_xy ( ) # # Make a copy of the data in the optimal order. # xy2 <- xy for ( i in 1 : n ) { xy2[i,1] = xy[order[i],1] xy2[i,2] = xy[order[i],2] } # # Repeat first city at end, to close the loop. # xy2 = rbind ( xy2, xy2[1,1:2] ) # # Plot the data. # filename = "tsp_dantzig42_graph.png" png ( filename ) plot ( xy2[,1], xy2[,2], xlab = "<--- X --->", ylab = "<--- Y --->", main = "TSP Dantzig42", col = "blue", type = 'l' ) grid ( nx = 5, ny = 5, col = "black" ) cat ( ' Graphics saved as "', filename, '"\n' ) # # Terminate. # cat ( "\n" ) cat ( "tsp_dantzig42_graph():\n" ) cat ( " Normal end of execution.\n" ) quit ( )