replaces tuples with vertex and edge classes