add function to split graph on components