There is swimlane example in mxgraph but it is not automatic. So I took the graphlayout example as a basis instead and made few changes:
Far from perfect, but somehow improvement:
Demo
I've added:
layout.execute(lane1, [v1,v2,v3,v4]); layout.execute(lane2, [v5,v6,v7,v8]);
and changed resizeParent to false, looks like lanes are respected but still don't look pleasant.
resizeParent
false