Changeset 110 in tspsg-svn for trunk/src/tspsolver.cpp


Ignore:
Timestamp:
Apr 28, 2010, 1:38:10 AM (15 years ago)
Author:
laleppa
Message:

+ Added ChangeLog?, Installation Guide and License pages to doxygen generated documentation.

  • Added city and separator parameters to CTSPSolver::getSortedPath() method to make path generation more flexible.
  • Fixed a bug when the solution graph wasn't drwan correctly in some situations.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tspsolver.cpp

    r107 r110  
    7171/*!
    7272 * \brief Returns the sorted optimal path, starting from City 1.
     73 * \param city A string that represents city elements in the path.
     74 * \param separator A string that represents separators between cities in the path.
    7375 * \return A string, containing sorted optimal path.
    74  */
    75 QString CTSPSolver::getSortedPath() const
     76 *
     77 *  The resulting path will be in the form \a city+\a separator+\a city+...+\a separator+\a city.
     78 *  \c \%1 in \a city will be replaced by the city number.
     79 */
     80QString CTSPSolver::getSortedPath(const QString &city, const QString &separator) const
    7681{
    7782        if (!root || route.isEmpty() || (route.size() != nCities))
     
    7984
    8085int i = 0; // We start from City 1
    81 QString path = tr("City %1").arg(1) + " -> ";
     86QStringList path;
     87        path << city.arg(1);
    8288        while ((i = route[i]) != 0) {
    83                 path += tr("City %1").arg(i + 1) + " -> ";
     89                path << city.arg(i + 1);
    8490        }
    8591        // And finish in City 1, too
    86         path += tr("City %1").arg(1);
    87 
    88         return path;
     92        path << city.arg(1);
     93
     94        return path.join(separator);
    8995}
    9096
Note: See TracChangeset for help on using the changeset viewer.