lisa/src/main/java/it/unive/lisa/analysis/nonrelational/value/impl/stringgraphdomain/SGNUtils.java
public static void replace(StringGraphNode<?> original, StringGraphNode<?> replacement) {
        if (!(original == replacement)) {
            List<StringGraphEdge> originalEdges = new ArrayList<>(original.getChildrenEdges());
            List<StringGraphNode<?>> originalBackwardParents = new ArrayList<>(original.getBackwardParents());
            for (StringGraphEdge e : originalEdges) {
                original.removeChild(e.getNode());
            }
            for (StringGraphNode<?> backwardParent : originalBackwardParents) {
                int originalIndex = backwardParent.getChildren().indexOf(original);
                backwardParent.addBackwardChild(originalIndex, replacement);
                backwardParent.removeChild(original);
            }
            if (!original.isRoot()) {
                StringGraphNode<?> forwardParent = original.getForwardParent();
                int originalIndex = forwardParent.getChildren().indexOf(original);
                forwardParent.addForwardChild(originalIndex, replacement);
                forwardParent.removeChild(original);
            }
        }
    }
/**
     * Replaces a StrigGraphNode with another instance of StringGraphNode
     *
     * @param original the node to be replaced
     * @param replacement the node that should take the place of original
     */
Replaces a StrigGraphNode with another instance of StringGraphNode
@param original the node to be replaced
@param replacement the node that should take the place of original
Replaces a StrigGraphNode with another instance of StringGraphNode @param original the node to be replaced @param replacement the node that should take the place of original
public static void replace(StringGraphNode<?> original, StringGraphNode<?> replacement) {
        if (!(original == replacement)) {
            List<StringGraphEdge> originalEdges = new ArrayList<>(original.getChildrenEdges());
            List<StringGraphNode<?>> originalBackwardParents = new ArrayList<>(original.getBackwardParents());
            for (StringGraphEdge e : originalEdges) {
                original.removeChild(e.getNode());
            }
            for (StringGraphNode<?> backwardParent : originalBackwardParents) {
                int originalIndex = backwardParent.getChildren().indexOf(original);
                backwardParent.addBackwardChild(originalIndex, replacement);
                backwardParent.removeChild(original);
            }
            if (!original.isRoot()) {
                StringGraphNode<?> forwardParent = original.getForwardParent();
                int originalIndex = forwardParent.getChildren().indexOf(original);
                forwardParent.addForwardChild(originalIndex, replacement);
                forwardParent.removeChild(original);
            }
        }
    }
public static void replace ( StringGraphNode < ? > original , StringGraphNode < ? > replacement ) { if ( ! ( original == replacement ) ) { List < StringGraphEdge > originalEdges = new ArrayList < > ( original . getChildrenEdges ( ) ) ; List < StringGraphNode < ? > > originalBackwardParents = new ArrayList < > ( original . getBackwardParents ( ) ) ; for ( StringGraphEdge e : originalEdges ) { original . removeChild ( e . getNode ( ) ) ; } for ( StringGraphNode < ? > backwardParent : originalBackwardParents ) { int originalIndex = backwardParent . getChildren ( ) . indexOf ( original ) ; backwardParent . addBackwardChild ( originalIndex , replacement ) ; backwardParent . removeChild ( original ) ; } if ( ! original . isRoot ( ) ) { StringGraphNode < ? > forwardParent = original . getForwardParent ( ) ; int originalIndex = forwardParent . getChildren ( ) . indexOf ( original ) ; forwardParent . addForwardChild ( originalIndex , replacement ) ; forwardParent . removeChild ( original ) ; } } }
Replaces a StrigGraphNode with another instance of StringGraphNode
 @param original the node to be replaced
 @param replacement the node that should take the place of original
Replaces a StrigGraphNode with another instance of StringGraphNode @param original the node to be replaced @param replacement the node that should take the place of original