Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I mainly need help on part C but feel free to fix A and B if you think they aren

ID: 3825721 • Letter: I

Question


I mainly need help on part C but feel free to fix A and B if you think they aren't right. Sorry it's sideways and please don't ask for a better picture it's the best I can get.

Thanks!

to question concerns Digraph class. the (10 points) (a) We want to add the operation converse to the class specification. The converse of a given digraph is the reversing each of the arcs. (Refer to the example on the board.) Show the declaration of this operation. Diag Void Con Va (b) Show how to Conver implement the converse operation. int temp (c) In a program that uses the Digraph class, implement the following function: int find triangle (int u, int v, Digraph g); //Assuming u and v are distinct nodes of g and (u, v) is an arc of g, this function finds a third node w such that both (w, u) and (v,w) are arcs of g. VIf no such node exists 0 is returned

Explanation / Answer

Code:

int find_triangle(int u, int v, Digraph g)
{
   // get the number of nodes in graph.
   int numOfNodes = sizeof(g)/sizeof(g[0]);
  
   int k = 0;
  
   // iterate through all the vertices of g.
for (k=0; k<numOfNodes; k++)
{
       // if all the values are 1, then there exists a node
       // with which triangle could be formed.
if (graph[u][v] && graph[v][k] && graph[k][u])
           return (k+1);
}   

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote