Computers and Technology

Java Question:

* blanancedFriendships
*
* say the 'balanceFactor' of a friendship is the difference between the two friends'
* popularities. If two friends have the same popularity, then the balanceFactor would
* be 0. If one of the friends had N total friends and the other had 1, then the
* balanceFactor would be N-1 - it would be a 'lopsided' friendship
*
* the maxBalanceFactor for a graph is the largest balanceFactor for the graph
* (note it would always be >=0)
*
* B-Level:
* determine the maximum balanceFactor for the graph.
* store the answer in the maxBalanceFactor instance variable
*
* A-Level
*
* determine the number of 'friendships' for which the balanceFactor is largest for the graph
* store the answer in the instance variable
*
* this level is optional. if you choose NOT to complete it, simply leave the assignment
* statement to as given below.
*
* Example: if all vertices have the same number of friends, then all popularites would be the same
* so all balanceFactors would be 0 - the maxBalanceFactor would be 0
*
* A-Level: since all balanceFactors are the same,
* all friendships would have the maximum balanceFactor
*
* Example: if one vertex 'a' was connected to 5 other vertices (b, c,d, e,f) and there were no other
* edges, then a's popularity would be 5, all the others would be 1. The balanceFactor for
* all friendships would be 4. the maxBalanceFactor would be 4
*
* A-Level: would be 5.
*
*/
private void blanancedFriendships(Graph G) {

maxBalanceFactor = -1; // ToDo 4 fix this

= -1; // toDo 5 optiona A Level fix this

}

More information that might be useful:

public class SocialCircles {
private int numberOfTrios; // the results of the computations are stored
private int[] indirectPopularity; // in these instance variables.
private int maxBalanceFactor; // the values of the variables may be accessed by clients using
private int ; // the corresponding 'accessor' functions below.
private int [] socialRank;

// accessor functions
public int getIndirectPopularity(int v) { // getIndirectPopularity of vertex v
return indirectPopularity[v];
}
public int getNumberOfTrios() {
return numberOfTrios;
}
public int getMaxBalanceFactor() {
return maxBalanceFactor;
}
public int () {
return ;
}
public int getSocialRank(int v) { // get getSocialRank of vertex v
return socialRank[v];
}

// ---end accessors

/**
* degree
*
* Suggestion. copy the degree function (or see if you can write it from scratch) from the textbook.
* you may find it a useful utility function for your functions
*/
public static int degree(Graph G, int v) {
int degree = 0;
for (int w : G. adj(v)) degree++;
return degree;
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, manyah6189
Amanda needs to create an informative print brochure for her local library’s fundraiser dinner. what critical detail must she have before she starts designing the brochure?
Answers: 1
image
Computers and Technology, 23.06.2019 06:30, Zieken993
Martha is designing a single-player game. her manager suggests that she plan the design to incorporate future modifications. which principle of game design relates to planning for future modifications?
Answers: 1
image
Computers and Technology, 23.06.2019 08:00, ionmjnm3041
The managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an .
Answers: 3
image
Computers and Technology, 23.06.2019 22:30, ghari112345
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
Do you know the correct answer?
Java Question:

* blanancedFriendships
*
* say the 'balanceFactor' of a frien...

Questions in other subjects: