3. Suppose that we want to know which agents are connected by a walk of length two in a given network. That is, want to know the set of ordered pairs (i, j) such that there exists a walk of length 2 between any i and j. Define n as the number of nodes and m as the number of links. (a) One way to do this is to input the adjacency matrix A, calculate A², then output all pairs (i, j) for which A(i) > 0. Defining scalar multiplication and addition as "basic operations," up to a constant c, how many "basic operations" are required to calculate A², in terms of n and m? (Hint: First think about how many operations are required to calculate each entry of A2, then multiply by the number of entries.) (b) Suppose that we want to know the number of agents who are connected by a walk of length k in a given network, where k ≥ 1. Up to a constant, how many basic operations are required to calculate Ak, in terms of n and m? (c) (Harder) We showed in class (Lecture 4) that a simple adaptation of Breadth-First Search (BFS) will calculate the length of the shortest path from any starting node i to all other nodes j in O(m) time. Taking this result as given, suggest an algorithm that runs in O(nm) time that will output all pairs (i, j) such that there is a path of length 2 between them, and briefly discuss why it runs in O(nm) time.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
3. Suppose that we want to know which agents are connected by a walk of length two in a given
network. That is, want to know the set of ordered pairs (i, j) such that there exists a walk
of length 2 between any i and j. Define n as the number of nodes and m as the number of
links.
(a) One way to do this is to input the adjacency matrix A, calculate A², then output all
pairs (i, j) for which A(i) > 0. Defining scalar multiplication and addition as "basic
operations," up to a constant c, how many "basic operations" are required to calculate
A², in terms of n and m? (Hint: First think about how many operations are required
to calculate each entry of A², then multiply by the number of entries.)
(b) Suppose that we want to know the number of agents who are connected by a walk of
length k in a given network, where k≥ 1. Up to a constant, how many basic operations
are required to calculate Ak, in terms of n and m?
(c) (Harder) We showed in class (Lecture 4) that a simple adaptation of Breadth-First
Search (BFS) will calculate the length of the shortest path from any starting node i to
all other nodes j in O(m) time. Taking this result as given, suggest an algorithm that
runs in O(nm) time that will output all pairs (i, j) such that there is a path of length 2
between them, and briefly discuss why it runs in O(nm) time.
(d) (Harder) Give conditions in terms of k, m, and n such that the algorithm in part (c) is
faster than the run time of the algorithm in part (a).
(e) (Harder) Similar to part (c), suppose that we use the adaptation of BFS to determine
which pairs of agents are connected by a walk of length k ≥ 1. Give conditions in terms
of k, m, and n such that this is faster than the run time of the algorithm in part (b).
Transcribed Image Text:3. Suppose that we want to know which agents are connected by a walk of length two in a given network. That is, want to know the set of ordered pairs (i, j) such that there exists a walk of length 2 between any i and j. Define n as the number of nodes and m as the number of links. (a) One way to do this is to input the adjacency matrix A, calculate A², then output all pairs (i, j) for which A(i) > 0. Defining scalar multiplication and addition as "basic operations," up to a constant c, how many "basic operations" are required to calculate A², in terms of n and m? (Hint: First think about how many operations are required to calculate each entry of A², then multiply by the number of entries.) (b) Suppose that we want to know the number of agents who are connected by a walk of length k in a given network, where k≥ 1. Up to a constant, how many basic operations are required to calculate Ak, in terms of n and m? (c) (Harder) We showed in class (Lecture 4) that a simple adaptation of Breadth-First Search (BFS) will calculate the length of the shortest path from any starting node i to all other nodes j in O(m) time. Taking this result as given, suggest an algorithm that runs in O(nm) time that will output all pairs (i, j) such that there is a path of length 2 between them, and briefly discuss why it runs in O(nm) time. (d) (Harder) Give conditions in terms of k, m, and n such that the algorithm in part (c) is faster than the run time of the algorithm in part (a). (e) (Harder) Similar to part (c), suppose that we use the adaptation of BFS to determine which pairs of agents are connected by a walk of length k ≥ 1. Give conditions in terms of k, m, and n such that this is faster than the run time of the algorithm in part (b).
Expert Solution
Overview

In this question we have to understand the given problem statement related to adjacency matrix operations and BFS algorithm with different parts from the question.

Here, as per the guidelines. Will be performing 3 parts solution and hope this helps you. If you face any query for the solution you may utilize Threaded Question Feature.

Let's understand and implement. 

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY