Question
Java Question: /** * socialRank * * for each vertex v, determine how many vertices have degree higher than v * how many people are
Java Question:
/** * 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) { for (int v= 0; v < G.V(); v++) { socialRank[v]=-1; // ToDo 3 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 numberOfMostUnbalancedFriendships; // 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 getNumberOfMostUnBlanancedFriendships() { return numberOfMostUnbalancedFriendships; } 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; }
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