Question
An Erdos-Renyi random graph G(n,p) is generated by two parameters -n: the number of vertices. -p: a number in [0,1], which is the probability that
An Erdos-Renyi random graph G(n,p) is generated by two parameters
-n: the number of vertices.
-p: a number in [0,1], which is the probability that each of the n(n-1)/2 edges is independently included in the graph.
Computing the size of the largest connected component. Given a graph G and a threshold t, write a function to test whether G contains a connected component of t vertices or more.
Input: a graph G and and a number t
Output: 1 if G contains a connected component of t vertices or more; 0 otherwise.
Hint: One solution is the following. For each vertex, you can compute the number of vertices in its connected component by BFS or DFS. Then, the function returns 1 if there exists a vertex whose connected component has at least t vertices. There are much faster ways to do this using BFS or DFS.
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