Program Listing for File PartitionWriter.hpp

Return to documentation for file (include/networkit/io/PartitionWriter.hpp)

/*
 * PartitionWriter.hpp
 *
 *  Created on: 22.01.2013
 *      Author: Christian Staudt
 */

#ifndef NETWORKIT_IO_PARTITION_WRITER_HPP_
#define NETWORKIT_IO_PARTITION_WRITER_HPP_

#include <fstream>

#include <networkit/structures/Partition.hpp>

namespace NetworKit {

class PartitionWriter final {

public:
    void write(const Partition &zeta, std::string_view path) const {
        std::ofstream file{path.data()};
        zeta.forEntries([&](node, const index c) { file << c << '\n'; });
    }
};

} /* namespace NetworKit */
#endif // NETWORKIT_IO_PARTITION_WRITER_HPP_