node/lib/metasm/metasm/gui/dasm_graph.rb
def create_layers(groups, order)
		newemptybox = lambda {
			b = Box.new(nil, [])
			b.x = -8
			b.y = -9
			b.w = 16
			b.h = 18
			groups << b
			b
		}

		newboxo = {}

		order.each_key { |g|
			og = order[g] || newboxo[g]
			g.to.dup.each { |gg|
				ogg = order[gg] || newboxo[gg]
				if ogg > og+1
					# long edge, expand
					sq = [g]
					(ogg - 1 - og).times { |i| sq << newemptybox[] }
					sq << gg
					gg.from.delete g
					g.to.delete gg
					newboxo[g] ||= order[g]
					sq.inject { |g1, g2|
						g1.to |= [g2]
						g2.from |= [g1]
						newboxo[g2] = newboxo[g1]+1
						g2
					}
					raise if newboxo[gg] != ogg
				end
			}
		}

		order.update newboxo

		# layers[o] = [list of nodes of order o]
		layers = []
		groups.each { |g|
			(layers[order[g]] ||= []) << g
		}

		layers
	end
# group groups in layers of same order
# create dummy groups along long edges so that no path exists between non-contiguous layers
group groups in layers of same order
create dummy groups along long edges so that no path exists between non-contiguous layers
group groups in layers of same order create dummy groups along long edges so that no path exists between non - contiguous layers
def create_layers(groups, order)
		newemptybox = lambda {
			b = Box.new(nil, [])
			b.x = -8
			b.y = -9
			b.w = 16
			b.h = 18
			groups << b
			b
		}
		newboxo = {}
		order.each_key { |g|
			og = order[g] || newboxo[g]
			g.to.dup.each { |gg|
				ogg = order[gg] || newboxo[gg]
				if ogg > og+1
					sq = [g]
					(ogg - 1 - og).times { |i| sq << newemptybox[] }
					sq << gg
					gg.from.delete g
					g.to.delete gg
					newboxo[g] ||= order[g]
					sq.inject { |g1, g2|
						g1.to |= [g2]
						g2.from |= [g1]
						newboxo[g2] = newboxo[g1]+1
						g2
					}
					raise if newboxo[gg] != ogg
				end
			}
		}
		order.update newboxo
		layers = []
		groups.each { |g|
			(layers[order[g]] ||= []) << g
		}
		layers
	end
def create_layers ( groups , order ) newemptybox = lambda { b = Box . new ( nil , [ ] ) b . x = - 8 b . y = - 9 b . w = 16 b . h = 18 groups << b b } newboxo = { } order . each_key { | g | og = order [ g ] || newboxo [ g ] g . to . dup . each { | gg | ogg = order [ gg ] || newboxo [ gg ] if ogg > og + 1 sq = [ g ] ( ogg - 1 - og ) . times { | i | sq << newemptybox [ ] } sq << gg gg . from . delete g g . to . delete gg newboxo [ g ] ||= order [ g ] sq . inject { | g1 , g2 | g1 . to |= [ g2 ] g2 . from |= [ g1 ] newboxo [ g2 ] = newboxo [ g1 ] + 1 g2 } raise if newboxo [ gg ] != ogg end } } order . update newboxo layers = [ ] groups . each { | g | ( layers [ order [ g ] ] ||= [ ] ) << g } layers end
group groups in layers of same order
create dummy groups along long edges so that no path exists between non-contiguous layers
group groups in layers of same order create dummy groups along long edges so that no path exists between non - contiguous layers
# long edge, expand # layers[o] = [list of nodes of order o]
groups
order