Exemple #1
0
void PrintShortestPathDict(const ShortestPathDict & pathDict) {
    printf("-------共有%d条最短路径信息-------\n", pathDict.size());
    for(ShortestPathDict::const_iterator iter = pathDict.begin(); iter != pathDict.end(); ++iter) {
        int from = (iter->first).first;
        int to = (iter->first).second;
        int cost = (iter->second).first;
        const std::pair<std::vector<int>, std::vector<int> > & path = (iter->second).second;
        const std::vector<int> & pathOfEdge = path.second;
        const std::vector<int> & pathOfPoint = path.first;
        printf("-------最短路径: 「%d」 --> 「%d」, 路径权重「%d」-------\n", from, to, cost);
        printf("\t经过的边集合:\t");
        bool firstBlood = false;
        for(std::vector<int>::const_iterator veciter = pathOfEdge.begin(); veciter != pathOfEdge.end(); ++veciter) {
            if(firstBlood){
                printf("->");
            }
            printf("%d", *veciter);
            firstBlood = true;
        }
        printf("\n");
        printf("\t经过的结点集合:\t");
        for(std::vector<int>::const_iterator veciter = pathOfPoint.begin(); veciter != pathOfPoint.end(); ++veciter)
            printf("%d->", *veciter);
        printf("%d\n", to);
    }
    printf("-------共有%d条最短路径信息-------\n", pathDict.size());
}
Exemple #2
0
void PrintShortestPathDict(const ShortestPathDict & pathDict) {
    printf("-------共有%d条最短路径信息-------\n", pathDict.size());
    for(ShortestPathDict::const_iterator iter = pathDict.begin(); iter != pathDict.end(); ++iter) {
        int from = (iter->first).first;
        int to = (iter->first).second;
        int cost = (iter->second).first;
        const std::vector<int> & path = (iter->second).second;
        printf("-------最短路径: 「%d」 --> 「%d」, 路径权重「%d」-------\n", from, to, cost);
        for(std::vector<int>::const_iterator veciter = path.begin(); veciter != path.end(); ++veciter)
            printf("%d ", *veciter);
        printf("\n");
    }
    printf("-------共有%d条最短路径信息-------\n", pathDict.size());
}