Answered step by step
Verified Expert Solution
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
CHW 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 edgenode incidence matrix of this graph. It is stored as a Dnumpy array friends.
Find the number of friend groups of this network. Store this value as numfriendgroups. This should be the number of connected components in this directed graph.
Assuming that a meme originates at person assume zeroindexing 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 nummemespread.
We also give you a function nullspace. Given a matrix as a dnumpy array of shape this function will return an numpy array of shape 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:
tableNameType,Descriptionfriendsnumpy array,edgenode incidence matrixnullspacefunction,returns basis of nullspace of a matrix
Your code snippet should define the following variables:
tableNameType,Descriptionnumfriendgroups,integer,Number of overall friend groupsnummemespread,integer,Number of people that will receive the meme
usercode.py
tableimport numpy as npimport numpy.linalg as latabletablenumfriendgroups dots
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