Program Listing for File DynSSSP.hpp

Return to documentation for file (include/networkit/distance/DynSSSP.hpp)

/*
 * DynSSSP.hpp
 *
 *  Created on: 17.07.2014
 *      Author: cls, ebergamini
 */

#ifndef NETWORKIT_DISTANCE_DYN_SSSP_HPP_
#define NETWORKIT_DISTANCE_DYN_SSSP_HPP_

#include <set>

#include <networkit/base/DynAlgorithm.hpp>
#include <networkit/distance/SSSP.hpp>
#include <networkit/dynamics/GraphEvent.hpp>
#include <networkit/graph/Graph.hpp>

namespace NetworKit {

class DynSSSP : public SSSP, public DynAlgorithm {

    friend class DynApproxBetweenness;

public:
    DynSSSP(const Graph &G, node source, bool storePredecessors = true, node target = none);

    ~DynSSSP() override = default;

    bool modified();
    void setTargetNode(node t = 0);

    const std::vector<node> &getPredecessors(node t) const;

protected:
    bool storePreds = true;
    bool mod = false;
    node target;
};

inline bool DynSSSP::modified() {
    return mod;
}

inline void DynSSSP::setTargetNode(const node t) {
    target = t;
}

inline const std::vector<node> &DynSSSP::getPredecessors(node t) const {
    if (!storePreds) {
        throw std::runtime_error("predecessors have not been stored");
    }
    return previous[t];
}

} /* namespace NetworKit */

#endif // NETWORKIT_DISTANCE_DYN_SSSP_HPP_