Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CHW 5 . 2 . Graphs: Meme spread in social networks Graphs can be used in mathematics and other fields to represent objects and the

CHW5.2. Graphs: Meme spread in social networks
Graphs can be used in mathematics and other fields to represent objects and the connections between them. Here, we will use a directed graph to represent people in a social network and their friend connections with one another. In this directed graph nodes correspond to people. An edge between two nodes indicates frienship between the correspding people. The direction of the edge is chosen at random and carries no further meaning. A friend group is a connected component of this graph. We will use this to model the spread of a meme throughout this theoretical social network.
We give you the edge-node incidence matrix of this graph. It is stored as a 2D-numpy array friends.
Find the number of friend groups of this network. Store this value as num_friend_groups. This should be the number of connected components in this directed graph.
Assuming that a meme originates at person 25(assume zero-indexing), find the number of people that will see the meme (including the original person). Assume each person will send the meme to all of their friends. Save this as num_meme_spread.
We also give you a function nullspace. Given a matrix as a 2d-numpy array of shape (m,n), this function will return an 2d-numpy array of shape (n,d) consisting of a basis of the nullspace of the original matrix.
The setup code gives the following variables:
The setup code gives the following variables:
\table[[Name,Type,Description],[friends,numpy array,edge-node incidence matrix],[nullspace,function,returns basis of nullspace of a matrix]]
Your code snippet should define the following variables:
\table[[Name,Type,Description],[num_friend_groups,integer,Number of overall friend groups],[num_meme_spread,integer,Number of people that will receive the meme]]
user_code.py
\table[[1,import numpy as np],[2,import numpy.linalg as la],[3,],[\table[[4],[5]],\table[[num_friend_groups =dots
image text in transcribed

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions