class AbstractLayout implements Layout {

    private final LayoutBuilder layoutBuilder;
    protected GraphModel graphModel;
    private boolean converged;

    public AbstractLayout(LayoutBuilder layoutBuilder) {
        this.layoutBuilder = layoutBuilder;
    }

    /**
     * See https://github.com/gephi/gephi/issues/603 Nodes position to NaN on applied layout
     *
     * @param graphModel
     */
    public static void ensureSafeLayoutNodePositions(GraphModel graphModel) {<FILL_FUNCTION_BODY>}

    @Override
    public LayoutBuilder getBuilder() {
        return layoutBuilder;
    }

    @Override
    public void setGraphModel(GraphModel graphModel) {
        this.graphModel = graphModel;
    }

    @Override
    public boolean canAlgo() {
        return !isConverged() && graphModel != null;
    }

    public boolean isConverged() {
        return converged;
    }

    public void setConverged(boolean converged) {
        this.converged = converged;
    }
}

        Graph graph = graphModel.getGraph();
        NodeIterable nodesIterable = graph.getNodes();
        for (Node node : nodesIterable) {
            if (node.x() != 0 || node.y() != 0) {
                nodesIterable.doBreak();
                return;
            }
        }

        //All at 0.0, init some random positions
        nodesIterable = graph.getNodes();
        for (Node node : nodesIterable) {
            node.setX((float) ((0.01 + Math.random()) * 1000) - 500);
            node.setY((float) ((0.01 + Math.random()) * 1000) - 500);
        }
    
<no_super_class>