Answered step by step
Verified Expert Solution
Link Copied!

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 & 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions