Counting vertices in Program is more efficient
Also set first=0 instead of None