public boolean isBipartite() {

        boolean isBipartite = true;

        for (Vertex v : vertexMap.values()) {
            if (!v.visited) {
                Queue<Vertex> q = new LinkedList<Vertex>();

                v.color = 1;
                v.visited = true;
                q.add(v);

                while (!q.isEmpty()) {

                    v = q.poll();
                    for (Edge e : v.adj) {
                        Vertex w = e.dest;
                        if (v.color == w.color) {
                            return false;
                        }
                        if (!w.visited) {
                            w.visited = true;
                            if (v.color == 1) {
                                w.color = 2;
                            } else {
                                w.color = 1;
                            }
                            q.add(w);
                        }
                    }

                }
            }
        }

        return isBipartite;

    }