public double calculateDensity(Graph graph, boolean isGraphDirected) {
        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;
    }
@Test
    public void testOneNodeDensity() {
        GraphModel graphModel = GraphGenerator.generateNullUndirectedGraph(1);
        Graph graph = graphModel.getGraph();
        GraphDensity d = new GraphDensity();
        double density = d.calculateDensity(graph, false);
        assertEquals(density, Double.NaN);
    }