Question: Implement the following C + + functions: AdjListGraph & generateAdjListGraph ( int numberOfNodes, double edgeProbability ) ; AdjMatrixGraph & generateAdjMatrixGraphGraph ( int numberOfNodes, double edgeProability

Implement the following C++ functions:
AdjListGraph & generateAdjListGraph(int numberOfNodes, double edgeProbability);
AdjMatrixGraph & generateAdjMatrixGraphGraph(int numberOfNodes, double edgeProability);
Each function will return a reference to a Graph containing the specified number of nodes with edges existing between each pair of nodes having the specified probability. This means that when you add a node to the graph, that there is an edgeProbability chance that you need to add an edge from the new node to each of existing nodes in the graph. Note that the probability test must occur for each existing node in the graph.
So, for numberOfNodes times, you will add a new node to the list and then loop through the nodes currently in the graph. In this loop, use the random number functions to generate a number in the range [0\ldots 1). If that number is greater than the edgeProbaility, then you need add an edge from your new node to the node youre examining.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!