MAINT: reorganize the code, splitting the graph transformation functions from the sampling functions