Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
ldots
If that number is greater than the edgeProbaility, then you need add an edge from your new node to the node you
re examining.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started