Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FIX THE TO DO /** * determineIndirectPopularity * * for each vertex v, determine the maximum popularity of its friends * store the answer in

FIX THE TO DO

/**

* determineIndirectPopularity

*

* for each vertex v, determine the maximum popularity of its friends

* store the answer in indirectPopularity[v]

*

*/

private void determineIndirectPopularity(Graph G) {

// ToDo 2 fix this

}

/**

* socialRank

*

* for each vertex v, determine how many vertices have degree higher than v

* "how many people are more popular than V?"

* store the answer in socialRank[v]

*/

private void determineSocialRank(Graph G) {

// ToDo 3 fix this

}

/**

* determineAverageNumberOfFriends

*

* Each vertex has some number of friends.

* Determine the average number of friends over all vertices

* store the answer in: averageNumberOfFriends

*/

private void determineAverageNumberOfFriends(Graph G) {

averageNumberOfFriends = -1; // ToDo 4 fix this

}

CLASS

public class Friendship {

private int numberOfTrios; // the results of the computations are stored

private int[] indirectPopularity; // in these instance variables.

private double averageNumberOfFriends; // the values of the variables may be accessed using

private int [] socialRank; // the corresponding 'accessor' functions below.

public int indirectPopularity(int v) { // accessor functions

return indirectPopularity[v];

}

public int numberOfTrios() {

return numberOfTrios;

}

public double averageNumberOfFriends() {

return averageNumberOfFriends;

}

public int socialRank(int v) {

return socialRank[v];

}

// ---end accessors

/**

* degree

*

* Suggestion. copy the degree function from the textbook.

* you may find it a useful utility function for your functions

*/

private int degree(Graph G, int v) {

int degree=0;

for(int w: G.adj(v)) degree++;

return degree; // fix this if you want to use it

}

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions