* @param b
     * @param layouts
     * @param dependOn
     * @param p
     * @param shared
     * @param position
     * @return
     */
    private boolean trySamplePositions(LayoutBox[] boxes,LayoutBox b,LayoutInfo[] layouts,int[] dependOn,int p,LinkedHashMap<LayoutInfo.NodeLayout, LayoutInfo.NodeLayout> shared,RelativePos position){
        //record all the current placed positions of shared nodes, to recover later
        ArrayList<LayoutInfo.NodeLayout> sharedCopy = new ArrayList<LayoutInfo.NodeLayout>(shared.size());
        for (LayoutInfo.NodeLayout nl : shared.keySet()) {
            sharedCopy.add(layouts[p].new NodeLayout(nl.processID, nl.nodeID, nl.cofactor, nl.x, nl.y));
        }

        boolean noOverlap=false;
        int sample=20;//half of the number of sample positions to try

        if(position.p == 0 || position.p == 1){//left or right cases, move vertically
            System.out.println("try sample positions vertically");
            double d = layouts[dependOn[p]].getExactLayoutBox().height /(2*sample);
            for(int i=0;i<sample;i++){
                double y = b.topleft.y + d*(i+1);
                LayoutBox tmpB = new LayoutBox(b.topleft.x,y,b.width,b.height);
                if(!overlapWithPlacedPathways(boxes,tmpB)){
                    System.out.println("succeeded a sample position");
                    applyLayoutInfo(layouts[p],0,y-b.topleft.y);
                    b = tmpB;
                    restorePositions(sharedCopy);
                    return true;
                }

                y = b.topleft.y - d*(i+1);
                tmpB = new LayoutBox(b.topleft.x,y,b.width,b.height);
                if(!overlapWithPlacedPathways(boxes,tmpB)){
                    System.out.println("succeeded a sample position");
                    applyLayoutInfo(layouts[p],0,y-b.topleft.y);
                    b = tmpB;
                    restorePositions(sharedCopy);
                    return true;
                }
            }
        }else{//top or below cases, move horizontally
            System.out.println("try sample positions horizontally");
            double d = layouts[dependOn[p]].getExactLayoutBox().width /(2*sample);
            for(int i=0;i<sample;i++){
                double y = b.topleft.x + d*(i+1);
                LayoutBox tmpB = new LayoutBox(b.topleft.x,y,b.width,b.height);
                if(!overlapWithPlacedPathways(boxes,tmpB)){
                    System.out.println("succeeded a sample position");
                    applyLayoutInfo(layouts[p],0,y-b.topleft.y);
                    b = tmpB;
                    restorePositions(sharedCopy);
                    return true;
                }

                y = b.topleft.y - d*(i+1);
                tmpB = new LayoutBox(b.topleft.x,y,b.width,b.height);
                if(!overlapWithPlacedPathways(boxes,tmpB)){
                    System.out.println("succeeded a sample position");
                    applyLayoutInfo(layouts[p],0,y-b.topleft.y);
                    b = tmpB;
                    restorePositions(sharedCopy);
                    return true;
                }
            }
        }
        return noOverlap;
    }