Answered step by step
Verified Expert Solution
Question
1 Approved Answer
There are going to be multiple cases throughout the semester where you are going to need to create directed graphs to test programs. Implement the
There are going to be multiple cases throughout the semester where you are going to need to create directed graphs to test programs. Implement the following functions:
AdjListGraph & generateAdjListGraphint numberOfNodes, double edgeProbability;
AdjMatrixGraph & generateAdjMatrixGraphGraphint 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 youre 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