implement bipartite graph