The length of the shortest path to the root of the poset hierarchy

var pos = new POSet[String]
pos.add_chain(["A", "B", "C", "D"])
assert pos["A"].depth == 3
assert pos["D"].depth == 0

Property definitions

poset $ POSetElement :: depth
	# The length of the shortest path to the root of the poset hierarchy
	#
	# ~~~~
	# var pos = new POSet[String]
	# pos.add_chain(["A", "B", "C", "D"])
	# assert pos["A"].depth == 3
	# assert pos["D"].depth == 0
	# ~~~~
	fun depth: Int do
		if direct_greaters.is_empty then
			return 0
		end
		var min = -1
		for p in direct_greaters do
			var d = poset[p].depth + 1
			if min == -1 or d < min then
				min = d
			end
		end
		return min
	end
lib/poset/poset.nit:621,2--641,4