moving code to UndirectedBase