Example #1
0
/**
 * 動作確認用コマンド
 */
int main()
{
	std::vector< std::set<size_t> > table;	// 有向グラフのテーブル

	table.resize(6);	// ノード数6 (0〜5)
	table[0].insert(2);	// 0 => 2
	table[2].insert(1);	// 2 => 1
	table[1].insert(4);	// 1 => 4

	if (!search_dfs(table, 0, 5)) {
		std::printf("NG (DFS)\n");	// 到達不可
	}

	if (!search_bfs(table, 0, 5)) {
		std::printf("NG (BFS)\n");	// 到達不可
	}

	table[4].insert(5);	// 4 => 5

	if (search_dfs(table, 0, 5)) {
		std::printf("OK (DFS)\n");	// 到達可
	}

	if (search_bfs(table, 0, 5)) {
		std::printf("OK (BFS)\n");	// 到達可
	}

	return 0;
}
Example #2
0
int main(void)
{
	search_bfs(a[0]);
	head = 0;
	while(qc > 0)
		putchar(outqueue());
		putchar('\n');
		destory();
		return 0;
}