if( !elementGraph.containsVertex( replaceWith ) )
elementGraph.addVertex( replaceWith );
for( Scope scope : incoming )
{
FlowElement source = elementGraph.getEdgeSource( scope );
elementGraph.removeEdge( source, replace ); // remove scope
// drop edge between, if any
if( source != replaceWith )
elementGraph.addEdge( source, replaceWith, scope ); // add scope back
}
for( Scope scope : outgoing )
{
FlowElement target = elementGraph.getEdgeTarget( scope );
elementGraph.removeEdge( replace, target ); // remove scope
// drop edge between, if any
if( target != replaceWith )
elementGraph.addEdge( replaceWith, target, scope ); // add scope back