Question: please complete the to do: /** * CountNumberOfTrios * determine how many groups of 3 vertices (u,v,w) are directly to connected to each other *
please complete the to do:
/**
* 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
}
the class is below:
import algs41.Graph;
import algs41.GraphGenerator;
import stdlib.*;
/**
* class Friendship version 1.0
* computes several 'friendship' related values for a graph
* You may add additional instance methods to the Friendship class to faciliate completing the ToDos
* You may NOT add any additional instance variables to the Friendship class
* You may use basic Java arrays, however you may NOT use any additional data structures without permission (e.g. queue)
*/
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
