Computer Science - Incidence Matrix - K-nearest Neighbours - Report Writing Assessment Answer

Download Solution Order New Solution

Computer Science Report Writing Assessment Answer

Task: 1 Implement the Graph Representations and their Operations (8 marks) In this task, you will implement the directed, weighted graph using the adjacency list and incidence matrix representations. Each representations will be implemented by a data structure. Your imple-mentation should support the following operations: · Create an empty directed graph (implemented as a constructor that takes zero arguments). Add a vertex to the graph. · Add an edge to the graph. · Get the weight of an edge in the graph. Update weight of edge in the graph. · Delete a vertex from the graph. · Compute the k-nearest in-neighbours of a vertex in the graph. Compute the k-nearest out-neighbours of a vertex in the graph. Print out the set of vertices of the graph. · Print out the set of edges and their weights of the graph. Data Structure Details Graphs can be implemented using a number of data structures. You are to implement the graph abstract data type using the following data structures: · Adjacency list, using an array of linked lists. · Incidence matrix, using a 2D array (an array of arrays). Operations Details Operations to perform on the implemented graph abstract data type are speci ed on the command line. They are in the following format: <operation> [arguments] where operation is one of fAV, AE, W, U, RV, IN, ON, PV, PE, Qg and arguments is for optional arguments of some of the operations. The operations take the following form: · AV <vertLabel> { add a vertex with label 'vertLabel' into the graph. · AE <srcLabel> <tarLabel> <weight> { add an edge with source vertex 'srcLabel', target ver-tex 'tarLabel' and edge weight 'weight' into the graph. · W <srcLabel> <tarLabel> { return weight of edge. If edge doesn't exist, return -1. · U <srcLabel> <tarLabel> <newWeight> { Update the weight of edge ('srcLabel', 'tarLabel) to 'newWeight' value. If 'newWeight' = 0, then delete the edge. · RV <vertLabel> { remove vertex 'vertLabel' from the graph. · IN <k> <vertLabel> { Return a set of k nearest in-neighbours for vertex 'vertLabel'. The ordering of the neighbours does not matter. If k = -1, then all neighbours should be returned. See below for the required format. · ON <k> <vertLabel> { Return a set of k nearest out-neighbours for vertex 'vertLabel'. The ordering of the neighbours does not matter. If k = -1, then all neighbours should be returned. See below for the required format. · PV { prints the vertex set of the graph. See below for the required format. The vertices can be printed in any order. · PE { prints the edge set of the graph. See below for the required format. The edges can be printed in any order. · Q { quits the program. The format of the output of a neighbour operation for vertex 'A' should take the form: A <(neighbour1,weight1) (neighbour2, weight2) ...> Each neighbour has its associated edge weight printed with it, e.g, neighbour1 and weight 1. If a vertex has no neighbours, then the neighbour list should be empty. The print vertex operation output the vertices in the graph in a single line. The line should speci es all the valid vertex (indices) in the graph. <vertex1> <vertex2> <vertex3> ... The print edge operation output the edges in the graph in over a number of lines. Each line speci es an edge in the graph, and should be in the following format: <srcVertex> <tarVertex> <weight> As an example of the operations, consider the output from the following list of operations: AV A AV B AV C AV D AV E AV F AE A B 1 AE C B 1 AE B D 1 AE A E 3 AE D C 5 AE F A 2 ON 1 A IN 1 F W C B W B C W A D U C B 4 U A B 0 RV D AV G PV PE Q The output from the two neighbour operations (`ON -1 A', `IN -1 F') should be: A (B, 2 ) (E , 3 ) F The output from operations to retrieve edge weights (`W C B', `W B C', 'W D C') should be: 1 1 5 The output from the print vertices operation (PV) could be (remember that the order doesn't matter): A B C E F G The output from the print edges operation (P E) could be (remember that the order doesn't matter): A E 3 C B 4 F A 2b Task B: Evaluate your Data Structures  In this second task, you will evaluate your two implemented structures in terms of their time com-plexities for the di erent operations and di erent use case scenarios. Scenarios arise from the possible use cases of a social/communication network. Write a report on your analysis and evaluation of the di erent implementations. Consider and recommend in which scenarios each type of implementation would be most appropriate. The report should be 8 pages or less, in font size 12. See the assessment rubric (Appendix A) for the criteria we are seeking in the report. Use Case Scenarios Typically, you use real usage data to evaluate your data structures. However, for this assignment, you will write data generators to enable testing over di erent scenarios of interest. We are also interested in the e ect of the density of the graph1 on these scenarios. There are many possibilities, but for this assignment, consider the following scenarios: Scenario 1 Shrinking graph (Removals): Although not often occurring for association graph, people do defriend/de-associate with each other. In this scenario, you are to evaluate the performance of your implementations in terms of: vertex removal edge removal Assume the graph that you start with is the one that we provided you with. You are to evaluate the performance the vertex and removal operations as the density of the initial graph is varied. Scenario 2 Nearest Neighbours: In this scenario, the graph is not changing, but important oper-ations such as neighbourhood are requested. Assume the graph that you start with is the one that we provided you with. You are to evaluate the performance of the the nearest neighbourhood implementations, for both in and out neighbourhoods, as the density of the initial graph and k are varied. Scenario 3 Changing associations (Update edge weights): In this scenario, associates between people are uctuating and the corresponding edge weights are changing. In this scenario, you are to evaluate the performance of your implementations in terms of: edge weight changes, both increases and decreases (but never enough to cause a weight to be 0 or less and subsequently be deleted). Assume the graph that you start with is the one that we provided you with. You are to evaluate the performance the edge weight operations as the density of the initial graph is varied. Data Generation When generating the vertices and edges to remove, nd neighbourhood and update edge weights for, the distribution of these elements, compared to what is in the graph already, will have an e ect on the timing performance. However, without the usage and query data, it is di cult to specify what this distributions might be. Instead, in this assignment, uniformly sample from a xed range, e.g., 0 to max vertex index of your graph when generating the vertices and edges for removing, nearest neighbourhoods and updating weights, and a di erent range when adding vertices (we do not want to repeatingly add vertices that are in the graph already). For generating graphs with di erent initial densities, you may want to either generate a series of add edge operations ('AE') to grow the graph to the desired density from the one we supplied, then evaluate for the appropriate scenario. Alternatively, you can consider writing a data generator within Java to insert directly into the data structures. Or can use one of the many great graph generators2 Whichever method you decide to use, remember to generate graphs of di erent densities to evaluate on. Due to the randomness of the data, you may wish to generate a few datasets with the same parameters settings (same graph density and a scenario) and take the average across a number of runs. Analysis In your analysis, you should evaluate each of your representations and data structures in terms of the di erent scenarios outlined above. Report Structure As a guide, the report could contain the following sections: Explain your data generation and experimental setup. Things to include are (brief) explanations of the generated data you decide to evaluate on, the density parameters you tested on, describe how the scenarios were generated (a paragraph and perhaps a gure or high level pseudo code su ce), which approach(es) you decide to use for measuring the timing results, and brie y describe the xed set(s) you used to generate the elements for vertex addition. Evaluation of the data structures using the generated data. Analyse, compare and discuss your results across di erent densities, representations and scenarios. Provide your explanation on why you think the results are as you observed. You may consider using the known theoretical time complexities of the operations of each data structure to help in your explanation. Summarise your analysis as recommendations, e.g., for this certain data scenario of this density, I recommend to use this data structure because... We suggest you refer to your previous analysis to help.
This Computer Science Assignment has been solved by our Computer Science experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.