Question: Java Question: Determine how many groups of 3 vertices (u,v,w) are directly to connected to each other. Each group should be counted only one time.
Java Question:
Determine how many groups of 3 vertices (u,v,w) are directly to connected to each other. Each group should be counted only one time. The functions stores the computed result in the numberOfTrios instance variable
private void countNumberOfTrios(Graph G) {
numberOfTrios = -1; // ToDo 1 fix this }
Important Information needed to answer the question:
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
Get step-by-step solutions from verified subject matter experts
