restructured code so that vertices have information about the topcode