Restructured program to display graph.