removed almost all asInstaceOf calls and moved to mutable graphs
WIP: added tests for intersections and unions