Facebook suggests people you may be (or should be) friends with. Netflix suggests movies you might...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Facebook suggests people you may be (or should be) friends with. Netflix suggests movies you might like. Amazon suggests products to buy. How do they do that? In this assignment, you will learn one simple way to make such suggestions. Representing a social network as a graph A graph or network represents relationships among things. The things are represented as nodes or vertices, and the relationships are represented as edges. One common use for a graph is to represent friendship among people in a social network. For example, here is the friendship graph for some of the characters of "Romeo and Juliet": Nurse Juliet 10 12 Capulet Tybalt Romeo Friar Laurence Benvolio 12 Montague Escalus Mercutio 8 Paris An edge between person A and person B means that A considers B a friend, and also B considers A a friend. A weight of an edge represents the closeness of two friends. The higher the score is the closer the two friends are. Recommending friends Your tasks are: 1. Build a graph to store the above Romeo and Juliet graph. You can use method Edge List or Adjacency List or Adjacency Matrix. (30 Points) 2. Recommend friends by closeness. (70 Points) For example, Capulet is in the recommendation list of Mercutio. The closeness between Capulet and Mercutio should be: 5(Mercutio-Paris)+3(Paris-Capulet) + 9(Mercutio-Escalus) + 2(Escalus- Capulet) You will ask user to type a name. For example: "Please type a name, and a recommendation list of people based on closeness will be displayed!" Then you will produce and print friend recommendations for this user based on closeness. For example, for Mercutio the list should be: Montague 32 Juliet 25 Friar Laurence 21 Capulet 19 Benvolio 12 3. You might find it necessary to implement the following methods in your classes, to create the method for task 2: 1) FriendCloseness: Prints the friends' names and the closeness. For example, Capulet is a friend of Paris, and the closeness is 3. 2) FriendsofFriends: Returns a friends of friends list. For example, Capulet should be in the friends of friends list of Mercutio. (Friends and self should not be put in this list); 3) CommonFriends: Returns a list of common friends of two people. For example, Mercutio has two friends in common with Capulet (Escalus and Paris); 4) NumberofCommonFriends(): Returns the number of common friends. For example, the number of common friends between Mercutio and Friar Laurence is one (Romeo); 5) Recommendby NumberofCommonFriends(): Prints recommended friends by number of common friends. You can do this by assigning each potential friend a number called a score (number of common friends), where higher scores indicate a better match. Then you can sort your list according to the score. Given user X, if two people Y and Z would be equally good as new friends for X (they have the same score), then they should be listed in alphabetical order (for names). For example, for Mercutio the list should be: Capulet Montague Benvolio Friar Laurence Juliet Facebook suggests people you may be (or should be) friends with. Netflix suggests movies you might like. Amazon suggests products to buy. How do they do that? In this assignment, you will learn one simple way to make such suggestions. Representing a social network as a graph A graph or network represents relationships among things. The things are represented as nodes or vertices, and the relationships are represented as edges. One common use for a graph is to represent friendship among people in a social network. For example, here is the friendship graph for some of the characters of "Romeo and Juliet": Nurse Juliet 10 12 Capulet Tybalt Romeo Friar Laurence Benvolio 12 Montague Escalus Mercutio 8 Paris An edge between person A and person B means that A considers B a friend, and also B considers A a friend. A weight of an edge represents the closeness of two friends. The higher the score is the closer the two friends are. Recommending friends Your tasks are: 1. Build a graph to store the above Romeo and Juliet graph. You can use method Edge List or Adjacency List or Adjacency Matrix. (30 Points) 2. Recommend friends by closeness. (70 Points) For example, Capulet is in the recommendation list of Mercutio. The closeness between Capulet and Mercutio should be: 5(Mercutio-Paris)+3(Paris-Capulet) + 9(Mercutio-Escalus) + 2(Escalus- Capulet) You will ask user to type a name. For example: "Please type a name, and a recommendation list of people based on closeness will be displayed!" Then you will produce and print friend recommendations for this user based on closeness. For example, for Mercutio the list should be: Montague 32 Juliet 25 Friar Laurence 21 Capulet 19 Benvolio 12 3. You might find it necessary to implement the following methods in your classes, to create the method for task 2: 1) FriendCloseness: Prints the friends' names and the closeness. For example, Capulet is a friend of Paris, and the closeness is 3. 2) FriendsofFriends: Returns a friends of friends list. For example, Capulet should be in the friends of friends list of Mercutio. (Friends and self should not be put in this list); 3) CommonFriends: Returns a list of common friends of two people. For example, Mercutio has two friends in common with Capulet (Escalus and Paris); 4) NumberofCommonFriends(): Returns the number of common friends. For example, the number of common friends between Mercutio and Friar Laurence is one (Romeo); 5) Recommendby NumberofCommonFriends(): Prints recommended friends by number of common friends. You can do this by assigning each potential friend a number called a score (number of common friends), where higher scores indicate a better match. Then you can sort your list according to the score. Given user X, if two people Y and Z would be equally good as new friends for X (they have the same score), then they should be listed in alphabetical order (for names). For example, for Mercutio the list should be: Capulet Montague Benvolio Friar Laurence Juliet
Expert Answer:
Answer rating: 100% (QA)
To complete the tasks we can create a Python program that represents the Romeo and Juliet friendship graph using an adjacency list Heres an example im... View the full answer
Related Book For
Auditing and Assurance services an integrated approach
ISBN: 978-0132575959
14th Edition
Authors: Alvin a. arens, Randal j. elder, Mark s. Beasley
Posted Date:
Students also viewed these programming questions
-
In this Assignment you will create a class that represents a Social Media profile (like a Facebook profile many of you have). The name of this class will be SocialMediaProfile . There are many things...
-
In this assignment you will be required to complete tasks related to job costing. Download the document, complete the required information, save the document, and submit the assignment in Blackboard....
-
In this assignment you will focus on forecasting demand for cruises in different geographical regions. CII is trying to determine which regions have faster-growing demand so that they can be sure to...
-
A group of fraud examiners is coordinating an investigation at a local law firm. Several lawyers at the firm are suspected of overbilling clients, possibly creating fake client accounts, and then...
-
As a marketing manager for one of the world??s largest automakers, you are responsible for the advertising campaign for a new energy-efficient sports utility vehicle. Your support team has prepared...
-
The following normal probability plot was constructed using part of the data appearing in the paper Trace Metals in Sea Scallops (Environmental Concentration and Toxicology 19: 13261334). The...
-
Shauna Washington started a business to sell art supplies and related curricula to home school families. The business grew quickly, with sales doubling three times during a five-year period. At that...
-
Applebaum Security Company is located in State H, which enables employers to reduce their contribution rates under the experience-rating system. From 1999 to 2008, inclusive, the company's total...
-
Monthly mortgage coupon rates should be calculated by simply dividing the annual rate by 12. You should also assume that all of the securities pay monthly. You should also divide annual interest...
-
What is the value of CP's revised offer on December 8 (before CP "sweetened" its offer by adding the CVR security)? In your analysis, assume the following: a) A valuation date of December 31, 2015,...
-
Define f : N^2 Z by f(x, y) = y x for all (x, y) N^2 . (a) Show that f is surjective. (b) Let S = {(x, y) N^2 : y = 2x 1}. Prove that f|S : S Z is injective
-
Peter Gunn Corporation's relevant range of activity is 7,000 units to 11,000 units. When it produces and sells 9,000 units, its average costs per unit are as follows: Average Cost per Unit Direct...
-
A British financial institution has written 1,200 call options and written 2,300 put options and holds (long) 800 put options on the euro (EUR). (Each option is to buy or sell 1 EUR.) The written...
-
1. The current par yield (the yield y that solves ParValue = +++ + 1+y (1+y) c is the coupon payment at the end of each year) curve is given by: C ParValue+c + + where (1+y)n Maturity (in year) 1 2 3...
-
What is June\'s cash ratio? Your client June has the following financial profile: Liquid Assets $44,000 Investment Assets $140,500 Personal Assets $195,500 Total Assets $380,000 Total Liabilities...
-
Beaver Inc. issues a 5,000,000 5-year, 8% fixed-rate interest note payable on December 31, 2022. Beaver Inc. is worried that interest rates may decrease which would increase the value of its debt so...
-
Consider a variant of the RR scheduling algorithm in which the quantum is proportional to the process burst time, for instance the quantum is 1/10 of the process burst time. Discuss this CPU...
-
Consider a game of poker being played with a standard 52-card deck (four suits, each of which has 13 different denominations of cards). At a certain point in the game, six cards have been exposed. Of...
-
The following is a partial audit program for the audit of sales transactions. 1. Foot the sales journal for one month and trace the postings to the general ledger. 2. Vouch entries in sales journal...
-
In using difference estimation, an auditor took a random sample of 100 inventory items from a large population to test for proper pricing. Several of the inventory items were misstated, but the...
-
What are the differences and similarities in audits of financial statements, compliance audits, and operational audits?
-
Solve the following standard maximum problem by the simplex algorithm: maximize: 2x1 x2 x3 + 4x4 - x1 + x2 3 subject to: x3 + X4 6 x + 2x2 + x3 + 2x4 10 x; 0 for all i
-
Verify that the list in formula (8) constitutes a basic feasible solution for the winery problem (3)-(4).
-
A small software production company wants to maximize the benefit of the time and money spent by its staff in working on development projects. It produces software that is roughly classified as one...
Study smarter with the SolutionInn App