Program Listing for File PredictionsSorter.hpp

Return to documentation for file (include/networkit/linkprediction/PredictionsSorter.hpp)

/*
 * PredictionsSorter.hpp
 *
 *  Created on: 26.04.2015
 *      Author: Kolja Esders
 */

#ifndef NETWORKIT_LINKPREDICTION_PREDICTIONS_SORTER_HPP_
#define NETWORKIT_LINKPREDICTION_PREDICTIONS_SORTER_HPP_

#include <networkit/linkprediction/LinkPredictor.hpp>

namespace NetworKit {

class PredictionsSorter final {
    struct ScoreComp {
        bool operator()(const LinkPredictor::prediction &a,
                        const LinkPredictor::prediction &b) const {
            return (a.second > b.second) || (a.second == b.second && a.first < b.first);
        }
    };

    static ScoreComp ConcreteScoreComp;

    struct NodePairComp {
        bool operator()(const LinkPredictor::prediction &a,
                        const LinkPredictor::prediction &b) const {
            return a.first < b.first;
        }
    };

    static NodePairComp
        ConcreteNodePairComp;

public:
    static void sortByScore(std::vector<LinkPredictor::prediction> &predictions);

    static void sortByNodePair(std::vector<LinkPredictor::prediction> &predictions);
};

} // namespace NetworKit

#endif // NETWORKIT_LINKPREDICTION_PREDICTIONS_SORTER_HPP_