class GraphDensity implements Statistics {

    /**
     * The density of the graph.
     */
    private double density;
    /**
     *
     */
    private boolean isDirected;

    public GraphDensity() {
        GraphController graphController = Lookup.getDefault().lookup(GraphController.class);
        if (graphController != null && graphController.getGraphModel() != null) {
            isDirected = graphController.getGraphModel().isDirected();
        }
    }

    public boolean getDirected() {
        return isDirected;
    }

    public void setDirected(boolean isDirected) {
        this.isDirected = isDirected;
    }

    public double getDensity() {
        return density;
    }

    @Override
    public void execute(GraphModel graphModel) {
        Graph graph;
        if (isDirected) {
            graph = graphModel.getDirectedGraphVisible();
        } else {
            graph = graphModel.getUndirectedGraphVisible();
        }

        density = calculateDensity(graph, isDirected);
    }

    public double calculateDensity(Graph graph, boolean isGraphDirected) {<FILL_FUNCTION_BODY>}

    /**
     * @return
     */
    @Override
    public String getReport() {
        NumberFormat f = new DecimalFormat("#0.000");

        return "<HTML> <BODY> <h1>Graph Density  Report </h1> "
            + "<hr>"
            + "<br>"
            + "<h2> Parameters: </h2>"
            + "Network Interpretation:  " + (isDirected ? "directed" : "undirected") + "<br>"
            + "<br> <h2> Results: </h2>"
            + "Density: " + f.format(density)
            + "</BODY></HTML>";
    }
}

        double result;

        double edgesCount = graph.getEdgeCount();
        double nodesCount = graph.getNodeCount();
        double multiplier = 1;

        if (!isGraphDirected) {
            multiplier = 2;
        }
        result = (multiplier * edgesCount) / (nodesCount * nodesCount - nodesCount);
        return result;
    
<no_super_class>