Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to write a function that makes a random undirected simple graph on python. def makegraph(n,p) it will take as input from the user

I'm trying to write a function that makes a random undirected simple graph on python.

def makegraph(n,p)

it will take as input from the user n nodes(vertices) and take p as input where p is probability between 0 and 1. The p will add edges randomly with a probabiliy of p.

and it will output a representation of the graph like

Print all adjacency lists with corresponding vertex:

0: [1, 2]

1: [2, 3]

2: [4]

3: [4, 5]

4: [5]

5: []

I tried using adjancy lists but have a hard time implementing the functions with it. Can someone please provide some code to point me in the right direction.

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

More Books

Students also viewed these Databases questions

Question

3 The distinction between microeconomics and macroeconomics.

Answered: 1 week ago