creates bi_partite graph from dictionary