Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.
HINTS:
There are some fancy language tricks you can use to make implementing these functions simpler (calling super class methods in C++ or taking advantage of duck typing in Python, for example). Think about it a bit before you try writing code.
Note that this is one way: new node to ALL other nodes in the graph. Choose wisely, as you may find you code running REALY slow.
Use the program you just created to guess the performance of the depth first search of a graph represented in an adjacency matrix. Generate graphs with sizes of 2,8,64,256, and 1024 nodes, each with a random number of edges, with edge probability of 0.5. Report how long (in seconds) it takes for your program to execute the search.

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions