0
/ 50
Given is the number of edges and vertices in a directed graph. Using this information return the density of the graph.
Number of possible...
Given is the number of edges and vertices in a directed graph. Using this information return the density of the graph.
Number of possible edges for a directed graph = 2 * ((n * (n - 1) / 2))
where n is the number of vertices
Density = (number of edges / number of possible edges)
If the graph only contains one vertex it has a density of 1.0
Examples:
density(5,5) -> 0.25
density(3,5) -> 0.8333333333333334
Your feedback will appear here when you check your answer.