summaryrefslogtreecommitdiffstats
path: root/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-11-13 23:06:17 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-11-13 23:06:17 +0100
commitc498a66df48f4a52b2b73a1ce7ca8001b2cc92bc (patch)
treef0249c1ae5f19b8aa34ca4228ced61408ac58026 /03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite
parenta80b82ef6c4214d16b5c6df76c90fb88f23329f7 (diff)
downloadcoursera-c498a66df48f4a52b2b73a1ce7ca8001b2cc92bc.zip
coursera-c498a66df48f4a52b2b73a1ce7ca8001b2cc92bc.tar.gz
Algorithms : add 03-algorithms_on_graphs 03-paths_in_graphs
Diffstat (limited to '03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite')
-rw-r--r--03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/bipartite.cpp24
-rw-r--r--03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/015
-rw-r--r--03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01.a1
-rw-r--r--03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/025
-rw-r--r--03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02.a1
5 files changed, 36 insertions, 0 deletions
diff --git a/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/bipartite.cpp b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/bipartite.cpp
new file mode 100644
index 0000000..f97eca5
--- /dev/null
+++ b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/bipartite.cpp
@@ -0,0 +1,24 @@
+#include <iostream>
+#include <vector>
+#include <queue>
+
+using std::vector;
+using std::queue;
+
+int bipartite(vector<vector<int> > &adj) {
+ //write your code here
+ return -1;
+}
+
+int main() {
+ int n, m;
+ std::cin >> n >> m;
+ vector<vector<int> > adj(n, vector<int>());
+ for (int i = 0; i < m; i++) {
+ int x, y;
+ std::cin >> x >> y;
+ adj[x - 1].push_back(y - 1);
+ adj[y - 1].push_back(x - 1);
+ }
+ std::cout << bipartite(adj);
+}
diff --git a/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01 b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01
new file mode 100644
index 0000000..010643f
--- /dev/null
+++ b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01
@@ -0,0 +1,5 @@
+4 4
+1 2
+4 1
+2 3
+3 1
diff --git a/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01.a b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01.a
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/01.a
@@ -0,0 +1 @@
+0
diff --git a/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02 b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02
new file mode 100644
index 0000000..2a3fbf4
--- /dev/null
+++ b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02
@@ -0,0 +1,5 @@
+5 4
+5 2
+4 2
+3 4
+1 4
diff --git a/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02.a b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02.a
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/03-algorithms_on_graphs/03-paths_in_graphs/02-bipartite/tests/02.a
@@ -0,0 +1 @@
+1