Question
/** * CountNumberOfTrios * * determine how many groups of 3 vertices (u,v,w) are directly to connected to each other * Each group should be
/**
* CountNumberOfTrios
*
* 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
}
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
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