Fix bug of network graph(#2847) and trivial code clean up.