changing graph structure to better access of vertex degree