
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for a university computer science exam focusing on the implementation of a mygraph class in java. Students are required to write a constructor and five methods for a weighted, undirected graph. The methods include checking graph properties (isweighted, isdirected), calculating node degrees (outdegree, indegree), and performing a depth-first search (dfs). The document also includes submission instructions and evaluation criteria.
Typology: Exams
1 / 1
This page cannot be seen from the preview
Don't miss anything!

public MyGraph (int [][] M) { // ... your code ... } // MyGraph
public boolean isWeighted(){ public boolean isDirected() { // … returns true if graph // … returns true if graph is // is weighted, else false // a directed graph, else false } // isWeighted } // delete public int outdegree(int x) { public int indegree(int x) { // returns outdegree of node x // returns indegree of node x } // outdegree } // indegree public String dfs (int x) { // … returns the order in which nodes are visited in a pre-order depth- // first search of the graph starting with node x. This method may // not be recursive. } // dfs