@SuppressWarnings("unchecked")
	public static <VertexType extends BaseVertex, EdgeType extends BaseEdge<VertexType>>
	boolean isBipartite(BaseGraph<VertexType, EdgeType> graph) {

		//Copying to ColorableVertex
		ColorableVertex<VertexType>[] CVArray =  (ColorableVertex<VertexType>[])Array.newInstance(ColorableVertex.class , graph.getVerticesCount());
		int i=0;
		for (VertexType vm : graph)
		{
			CVArray[i] = new ColorableVertex<VertexType>(vm);
			i++;
		}



		LinkedList<ColorableVertex<VertexType>> queue = new LinkedList<ColorableVertex<VertexType>>();
		ColorableVertex<VertexType> cv = CVArray[0];

		for (ColorableVertex<VertexType> v : CVArray)
		{
			if (v.color>0) continue;

			v.color = 1;
			queue.offer(v);

			while (queue.size() != 0) {	
				cv = queue.poll();
				for (ColorableVertex<VertexType> next : CVArray) {
					if (graph.isEdge(cv.vm, next.vm)) 
					{
						if(next.color == 0)
						{
							next.color = 3 - cv.color;
							queue.offer(next);
						}
						else if(cv.color == next.color)
							return false;
					}
				}

			}
		}

		return true;
	}