<commit_before>/*
 * METISGraphReader.cpp
 *
 *  Created on: 17.01.2013
 *      Author: <NAME> (<EMAIL>)
 */

#include "METISGraphReader.h"

namespace NetworKit {

METISGraphReader::METISGraphReader() {

}

METISGraphReader::~METISGraphReader() {

}


Graph METISGraphReader::read(std::string path) {

	METISParser parser(path);

	std::tuple<count, count, index> header = parser.getHeader();
	count n = std::get<0>(header);
	count m = std::get<1>(header);
	index weighted = std::get<2>(header);
	//std::tie(n,m,weighted) = header;
	// TODO: std::tie(n, m, weighted) = header

	Graph G(n);

	std::string graphName = Aux::StringTools::split(Aux::StringTools::split(path, '/').back(), '.').front();

	G.setName(graphName);

	DEBUG("[BEGIN] reading graph G(n=", n, ", m=", m, ") from METIS file: ", graphName);	// progress bar follows

	double p = 0.0; // percentage for progress bar
	node u = 0; // begin with 0

	if (weighted == 0) {
		while (parser.hasNext()) {
			std::vector<node> adjacencies = parser.getNext();
			for (index i=0; i < adjacencies.size(); i++) {

				node v = adjacencies[i] - 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G.addEdge(u, v);
				}
			}
			u++; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		DEBUG("[DONE]\n");
		return G;
	} else {
		while (parser.hasNext()) {

			std::vector<std::pair<node,double>> adjacencies = parser.getNextWithWeights();

			for (index i=0; i < adjacencies.size(); i++) {
				node v = adjacencies[i].first- 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G.addEdge(u, v);
					G.setWeight(u, v, adjacencies[i].second);
					assert(adjacencies[i].second > 0);
				}
			}
			u += 1; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		DEBUG("[DONE]\n");
		return G;
	}
}

Graph* METISGraphReader::readToHeap(std::string path) {
	METISParser parser(path);

	std::tuple<count, count, index> header = parser.getHeader();
	count n = std::get<0>(header);
	count m = std::get<1>(header);
	index weighted = std::get<2>(header);
	//std::tie(n,m,weighted) = header;
	// TODO: std::tie(n, m, weighted) = header

	Graph* G = new Graph(n);

	std::string graphName = Aux::StringTools::split(Aux::StringTools::split(path, '/').back(), '.').front();

	G->setName(graphName);

	DEBUG("[BEGIN] reading graph G(n=", n, ", m=", m, ") from METIS file: ", graphName);	// progress bar follows

	double p = 0.0; // percentage for progress bar
	node u = 0; // begin with 0

	if (weighted == 0) {
		while (parser.hasNext()) {
			std::vector<node> adjacencies = parser.getNext();
			for (index i=0; i < adjacencies.size(); i++) {

				node v = adjacencies[i] - 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G->addEdge(u, v);
				}
			}
			u++; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		DEBUG("[DONE]\n");
		return G;
	} else {
		while (parser.hasNext()) {

			std::vector<std::pair<node,double>> adjacencies = parser.getNextWithWeights();

			for (index i=0; i < adjacencies.size(); i++) {
				node v = adjacencies[i].first- 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G->addEdge(u, v);
					G->setWeight(u, v, adjacencies[i].second);
					assert(adjacencies[i].second > 0);
				}
			}
			u += 1; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				std::cout << p << "% " << std::flush;
			}
		}
		DEBUG("[DONE]\n");
		return G;
	}}

} /* namespace NetworKit */<commit_msg>logging in METISGraphReader<commit_after>/*
 * METISGraphReader.cpp
 *
 *  Created on: 17.01.2013
 *      Author: <NAME> (<EMAIL>)
 */

#include "METISGraphReader.h"

namespace NetworKit {

METISGraphReader::METISGraphReader() {

}

METISGraphReader::~METISGraphReader() {

}


Graph METISGraphReader::read(std::string path) {

	METISParser parser(path);

	std::tuple<count, count, index> header = parser.getHeader();
	count n = std::get<0>(header);
	count m = std::get<1>(header);
	index weighted = std::get<2>(header);
	//std::tie(n,m,weighted) = header;
	// TODO: std::tie(n, m, weighted) = header

	Graph G(n);

	std::string graphName = Aux::StringTools::split(Aux::StringTools::split(path, '/').back(), '.').front();

	G.setName(graphName);

	INFO("\n[BEGIN] reading graph G(n=", n, ", m=", m, ") from METIS file: ", graphName);	// progress bar follows

	double p = 0.0; // percentage for progress bar
	node u = 0; // begin with 0

	if (weighted == 0) {
		while (parser.hasNext()) {
			std::vector<node> adjacencies = parser.getNext();
			for (index i=0; i < adjacencies.size(); i++) {

				node v = adjacencies[i] - 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G.addEdge(u, v);
				}
			}
			u++; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		INFO("\n[DONE]\n");
		return G;
	} else {
		while (parser.hasNext()) {

			std::vector<std::pair<node,double>> adjacencies = parser.getNextWithWeights();

			for (index i=0; i < adjacencies.size(); i++) {
				node v = adjacencies[i].first- 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G.addEdge(u, v);
					G.setWeight(u, v, adjacencies[i].second);
					assert(adjacencies[i].second > 0);
				}
			}
			u += 1; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		INFO("\n[DONE]\n");
		return G;
	}
}

Graph* METISGraphReader::readToHeap(std::string path) {
	METISParser parser(path);

	std::tuple<count, count, index> header = parser.getHeader();
	count n = std::get<0>(header);
	count m = std::get<1>(header);
	index weighted = std::get<2>(header);
	//std::tie(n,m,weighted) = header;
	// TODO: std::tie(n, m, weighted) = header

	Graph* G = new Graph(n);

	std::string graphName = Aux::StringTools::split(Aux::StringTools::split(path, '/').back(), '.').front();

	G->setName(graphName);

	INFO("\n[BEGIN] reading graph G(n=", n, ", m=", m, ") from METIS file: ", graphName);	// progress bar follows

	double p = 0.0; // percentage for progress bar
	node u = 0; // begin with 0

	if (weighted == 0) {
		while (parser.hasNext()) {
			std::vector<node> adjacencies = parser.getNext();
			for (index i=0; i < adjacencies.size(); i++) {

				node v = adjacencies[i] - 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G->addEdge(u, v);
				}
			}
			u++; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				DEBUG(p, "% ");
			}
		}
		INFO("\n[DONE]\n");
		return G;
	} else {
		while (parser.hasNext()) {

			std::vector<std::pair<node,double>> adjacencies = parser.getNextWithWeights();

			for (index i=0; i < adjacencies.size(); i++) {
				node v = adjacencies[i].first- 1; 	// METIS-indices are 1-based
				assert (v >= 0);
				if (u <= v) { // self-loops are allowed
					G->addEdge(u, v);
					G->setWeight(u, v, adjacencies[i].second);
					assert(adjacencies[i].second > 0);
				}
			}
			u += 1; // next node
			if ((u % ((n + 10)/10)) == 0) {
				p = ((double) (u-1) / (double) n) * 100;
				std::cout << p << "% " << std::flush;
			}
		}
		INFO("\n[DONE]\n");
		return G;
	}}

} /* namespace NetworKit */
{'fraction_non_alphanumeric': 0.2144167758846658, 'fraction_numerical': 0.020969855832241154, 'mean_word_length': 2.984856396866841, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7560263', 'n_tokens_mistral': 3469, 'n_tokens_neox': 2919, 'n_words': 702}