def findprev(layer, cols):
	"""For a particular column in a particular layer, find the next earlier
	column in the layer that contains a node
	"""
	found = -1
	pos = cols - 1
	while (pos >= 0) and (found < 0):
		if layer[pos] == 1:
			found = pos
		pos = pos - 1
	return found