# Class: com.pnfsoftware.jeb.core.units.code.android.controlflow.AbstractGraphReorganizer

Facility for CFG graph nodes reordering and graph address shifting.

## Constructor: AbstractGraphReorganizer
- parameter: `cfg`, type: `com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<InsnType>`

Description: Create a graph reorganizer.
parameter: cfg: CFG to reorganize

## Protected Method: canFallthrough
- parameter: `insn`, type: `InsnType`
- return type: `boolean`

Description: Determine if the provided instruction is a flow breaker that falls\-through \(or may, if it's a conditional branch\) into the first instruction of the next block.
parameter: insn: instruction to test
return: true if the instruction can fall through

## Protected Method: createNop
- parameter: `insnOffset`, type: `long`
- parameter: `insnSize`, type: `int`
- return type: `InsnType`

Description: Create a no\-operation instruction.
parameter: insnOffset: new instruction offset
parameter: insnSize: instruction size
return: the no\-operation instruction

## Protected Method: createTrampoline
- parameter: `insnOffset`, type: `long`
- parameter: `tempTarget`, type: `long`
- return type: `InsnType`

Description: Create a trampoline instruction.
parameter: insnOffset: new instruction offset
parameter: tempTarget: temporary target offset
return: the trampoline instruction

## Method: getConversionMap
- return type: `java.util.Map<java.lang.Long,java.lang.Long>`

Description: Retrieve a map holding the old offsets to their corresponding new offsets, in the reorganized CFG.
return: the old\-to\-new offset map, or null if no reorganization was performed

## Method: getReorganizedCfg
- return type: `com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<InsnType>`

Description: Retrieve a CFG reorganized by [#reorder(int[])](#reorder(int[])).
return: the reorganized CFG, or null if no reorganization was performed

## Protected Method: hasTargets
- parameter: `insn`, type: `InsnType`
- return type: `boolean`

Description: Determine whether the instruction has targets that may be updated.
parameter: insn: instruction to test
return: true if the instruction has updateable targets

## Method: reorder
- parameter: `newOrder`, type: `int[]`
- return type: `com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<InsnType>`

Description: Reorder the basic blocks of the CFG.
parameter: newOrder: an array of 0\-based indices from 0 to n\-1; providing \[0, 1, ..., n\-1\] does            nothing
return: a reordered CFG; null if the provided order was the original order

## Method: shift
- parameter: `shsize`, type: `int`

Description: Shift the CFG 'downward', ie, all addresses. This method works in\-place; no new CFG is created \(unlike [#reorder(int[])](#reorder(int[]))\).
parameter: shsize: a strictly positive value; else the method will throw

## Protected Method: updateInstructionOffset
- parameter: `insn`, type: `InsnType`
- parameter: `insnOffset`, type: `long`
- return type: `InsnType`

Description: Update or copy the provided instruction and set its offset. It is up to the implementation to decide whether instructions should be copied \(consequence: the original CFG may be fully preserved, at the cost of speed and resources\) or reused.
parameter: insn: original instruction
parameter: insnOffset: new offset
return: the provided instruction \(updated\), or a new \(copy\) of the instruction with the         provided offset

## Protected Method: updateTargets
- parameter: `insn`, type: `InsnType`
- parameter: `map`, type: `java.util.Map<java.lang.Long,java.lang.Long>`

Description: Update the targets of an instruction.
parameter: insn: instruction to update
parameter: map: old\-to\-new target offset map

## Protected Method: updateTrampolineTarget
- parameter: `insn`, type: `InsnType`
- parameter: `target`, type: `long`

Description: Update the target of a trampoline instruction.
parameter: insn: must be a trampoline instruction
parameter: target: new target offset

