Answered step by step
Verified Expert Solution
Link Copied!

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
[
0
\
ldots
1
)
.
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

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_2

Step: 3

blur-text-image_3

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Describe loss aversion and myopic loss aversion.

Answered: 1 week ago