def density(self):
        """
        In mathematics, a dense graph is a graph in which the number of edges
        is close to the maximal number of edges. The opposite, a graph with
        only a few edges, is a sparse graph. The distinction between sparse
        and dense graphs is rather vague, and depends on the context.

        For undirected simple graphs, the graph density is defined as:
        D = (2*No-Of-Edges)/((v*(v-1))/2)
        For a complete Graph, the Density D is 1
        """
        """ method to calculate the density of a graph """
        V = len(self.v.keys())
        E = len(self.getEdges())
        return 2.0 * E / (V *(V - 1))

        In mathematics, a dense graph is a graph in which the number of edges
        is close to the maximal number of edges. The opposite, a graph with
        only a few edges, is a sparse graph. The distinction between sparse
        and dense graphs is rather vague, and depends on the context.

        For undirected simple graphs, the graph density is defined as:
        D = (2*No-Of-Edges)/((v*(v-1))/2)
        For a complete Graph, the Density D is 1
        
recipes/Python/579141_Simple_Graph_library/recipe-579141.py