jkunlin 8 tahun lalu
induk
melakukan
1d121b4687

+ 0 - 0
dimacs2metis.cpp → graph_format/dimacs2metis.cpp


+ 0 - 0
dimacs2txt.cpp → graph_format/dimacs2txt.cpp


+ 0 - 0
graphml2dimacs.py → graph_format/graphml2dimacs.py


+ 0 - 0
test_dimacs.cpp → graph_format/test_dimacs.cpp


+ 0 - 0
dfmax.c → machine_benchmark/dfmax.c


+ 0 - 0
dfmax_boost.cpp → machine_benchmark/dfmax_boost.cpp


+ 0 - 0
prun.py → run_tools/prun.py


+ 55 - 0
run_tools/prun.sh

@@ -0,0 +1,55 @@
+# !/bin/bash
+
+SEND_THREAD_NUM=2
+tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
+mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
+exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
+rm $tmp_fifofile
+for ((i=0; i<SEND_THREAD_NUM; i++));do
+	echo # for循环 往 fifo管道文件中写入 $SEND_THREAD_NUM 个空行
+done >&6
+
+CUTOFF_TIME=1000
+
+instance_dirs="bio col fb inf int rec ret sci soc tec web"
+
+all_results_dir=$1
+graph_dir="/home/pkutcs/graphs"
+if [ -d "$all_results_dir" ]
+then
+	echo "warning: $all_results_dir exist"
+	exit 0
+fi
+mkdir "$all_results_dir"
+
+for seed in $(seq 1 10)
+do
+	echo "*************    $seed    *****************"
+	for ins_dir in $instance_dirs
+	do
+		echo "$ins_dir"
+		res_dir="$all_results_dir"/"$ins_dir"
+		if [ ! -d "$res_dir" ]
+		then
+			mkdir "$res_dir"
+		fi
+		find  "$graph_dir/$ins_dir" -maxdepth 1 -mindepth 1 |
+		while read instance
+		do
+			read -u6
+			{
+				instance=$(basename "$instance")$
+				res_dir="$res_dir"/"$instance"
+				if [ ! -d "$res_dir" ]
+				then
+					mkdir "$res_dir"
+				fi
+				res_file="$res_dir"/"$instance"_$seed
+				echo "$graph_dir/$ins_dir/$instance" "$CANDIDATE" "$seed" "$CUTOFF_TIME" > "$res_file"
+				echo >&6
+			} &
+		done
+	done
+done
+
+exit 0

+ 151 - 0
subgraph.cpp

@@ -0,0 +1,151 @@
+// =====================================================================================
+//
+//       Filename:  subgraph.cpp
+//
+//    Description:  output subgraph
+//
+//        Version:  1.0
+//        Created:  2018年 01月 08日 星期一 16:09:22 CST
+//       Revision:  none
+//       Compiler:  g++
+//
+//         Author:  Jinkun Lin, jkunlin@gmail.com
+//   Organization:  School of EECS, Peking University
+//
+// =====================================================================================
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include <algorithm>
+using namespace std;
+
+vector<vector<int>> adjacency_list;
+
+// read graph file into adjacency_list
+void fast_read(string file_name) {
+	ifstream in_file(file_name);
+	if (!in_file) {
+		cout << "in_file error" << endl;
+		exit(1);
+	}
+	in_file.seekg (0, in_file.end);
+	size_t file_len = in_file.tellg();
+	in_file.seekg (0, in_file.beg);
+	char *data = new char [file_len];
+
+	in_file.read(data, file_len);
+	in_file.close();
+
+	data[file_len - 1] = '\0';
+
+	//skip comments
+	char *pos = data;
+	while (*pos == 'c') {
+		while(*(pos++) != '\n');
+	}
+
+	//read vertex_count
+	int vertex_count = 0, edge_count = 0;
+	while (*pos < '0' || *pos > '9') {
+		++pos;
+	}
+	while (*pos != ' ') {
+		vertex_count = vertex_count * 10 +  *pos - '0';
+		++pos;
+	}
+	//read edge_count
+	while (*pos < '0' || *pos > '9') {
+		++pos;
+	}
+	while (*pos >= '0' && *pos <= '9') {
+		edge_count = edge_count * 10 +  *pos - '0';
+		++pos;
+	}
+
+	//read adjacency_list
+	adjacency_list.resize(vertex_count + 1);
+
+	vector<int> vertex_degree(vertex_count + 1, 0);
+	char *stash_pos = pos;
+	int v1, v2;
+	for (int i = 0; i < edge_count && *pos != '\0'; ++i) {
+		v1 = v2 = 0;
+		//read v1
+		while (*pos < '0' || *pos > '9') {
+			++pos;
+		}
+		while (*pos != ' ') {
+			v1 = v1 * 10 +  *pos - '0';
+			++pos;
+		}
+		//read v2
+		while (*pos < '0' || *pos > '9') {
+			++pos;
+		}
+		while (*pos >= '0' && *pos <= '9') {
+			v2 = v2 * 10 +  *pos - '0';
+			++pos;
+		}
+		vertex_degree[v1]++;
+		vertex_degree[v2]++;
+	}
+	for (size_t v = 1; v < adjacency_list.size(); ++v) {
+		adjacency_list[v].reserve(vertex_degree[v]);
+	}
+	pos = stash_pos;
+	for (int i = 0; i < edge_count && *pos != '\0'; ++i) {
+		v1 = v2 = 0;
+		//read v1
+		while (*pos < '0' || *pos > '9') {
+			++pos;
+		}
+		while (*pos != ' ') {
+			v1 = v1 * 10 +  *pos - '0';
+			++pos;
+		}
+		//read weight
+		while (*pos < '0' || *pos > '9') {
+			++pos;
+		}
+		while (*pos >= '0' && *pos <= '9') {
+			v2 = v2 * 10 +  *pos - '0';
+			++pos;
+		}
+		adjacency_list[v1].push_back(v2);
+		adjacency_list[v2].push_back(v1);
+	}
+	delete[] data;
+}
+
+int main(int argc, char const *argv[]) {
+	if (argc != 2) {
+		std::cout << "usage" << std::endl;
+		return 1;
+	}
+	string input_filename =argv[1];
+	fast_read(input_filename);
+
+	vector<int> vertex;
+	int v;
+	vector<int> indicator(adjacency_list.size(), 0);
+	std::cout << "input vertex:" << std::endl;
+	while (cin >> v) {
+		if (indicator[v] == 0) {
+			vertex.push_back(v);
+			indicator[v] = 1;
+		}
+	}
+	std::sort(vertex.begin(), vertex.end());
+
+	for (auto v : vertex) {
+		std::cout << v << " : ";
+		for (auto u : adjacency_list[v]) {
+			if (indicator[u]) {
+				cout << u << ' ';
+			}
+		}
+		std::cout << std::endl;
+	}
+	return 0;
+}