public void reduceGraph(ArrayList<GraphNode> twoWallsNodes){        
        if(twoWallsNodes.isEmpty()) return;
        
        ArrayList<GraphNode> nodeList = new ArrayList<>();
        nodeList.addAll(twoWallsNodes);
        for(GraphNode node:nodeList){
            if(node.isGoodFood()){
                twoWallsNodes.remove(node);
                continue;
            }
            if(node.getNeighbors().size()==2){
                Edge a = node.getNeighbors().get(0);
                Edge b = node.getNeighbors().get(1);
                int edgeCost = a.getStates().size()+b.getStates().size()+2;

                Edge ab = new Edge(b.getGNode(),edgeCost);
                ArrayList<Point> ABStates = new ArrayList<>();
                if(!a.getStates().isEmpty()){
                    ABStates.addAll(a.getStates());
                    Collections.reverse(ABStates);
                }                
                ABStates.add(new Point(node.getX(),node.getY()));
                if(!b.getStates().isEmpty()){
                    ABStates.addAll(b.getStates());
                }
                ab.setStates(ABStates);

                Edge ba = new Edge(a.getGNode(),edgeCost);
                ArrayList<Point> BAStates = new ArrayList<>();
                BAStates.addAll(ABStates);
                Collections.reverse(BAStates);
                ba.setStates(BAStates);

                a.getGNode().addEdge(ab);
                b.getGNode().addEdge(ba);
                a.getGNode().removeNeighbor(node);
                b.getGNode().removeNeighbor(node);
                twoWallsNodes.remove(node);
                eraseNode(node);
            }
        }
    }