Chain graph models: topological sorting of meta-arrows and efficient construction of B-essential graphs