{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

We require your implementation of kruskals algorithm

Info iconThis preview shows pages 5–7. Sign up to view the full content.

View Full Document Right Arrow Icon
We require your implementation of Kruskal’s algorithm to run in O(ElogV) , with E being the number of edges and V being the number of nodes. You should return a HashSet<Edge> and also output to a file called MST.out in the following format: 123;345 325;345 345;789 Each number is the Fakebook ID of a node. In the example above, each line represents a single edge from one node to another, e.g. the first line represents an edge from node 123 to 345. The example above represents an MST of the following graph (with edge weights = 1000/(mutual friends + 1), or 500, 500, 500, 1000 from left to right): Note that there can be multiple valid MSTs for a particular graph. If this is the case, returning any of them is fine. 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Once you have completed this task, generate a file MST.out using the input 300.json. Now, you will visualize the results of your calculations with Gephi, a graph visualization tool. Download Gephi from https://gephi.org/users/download/. Save the contents of MST.out into a csv filed called MST.csv. To load your graph, click “File”, select “Open”, locate your MST.csv, and then press “Open”. In Graph Type, choose the “Undirected” tab, and then press OK. Your graph should now appear (If not, select Window — Graph). Play with your graph a bit - change the layout (on the left side) so you can better see the spanning tree, show the node labels, color the graph. You won’t be able to draw the graph such that no edges cross. Once the graph looks meaningful (just a blob of nodes and edges will receive no credit), take a screenshot of your graph and save it as MST.jpg. Feel free to use Gephi to visualize your graph at any point by saving the edges in a csv file and following the above instructions. 3.2 Measures of Centrality The following exercises will examine different ways of defining metrics for social graphs. 3.2.1 DegreeCentrality.java 10pts Degree centrality is the simplest measure of centrality and is defined as the number of edges that are incident on a node. Find the degree centrality for a given node in our friend graph by implementing the following method in DegreeCentrality.java : public static int getDegree(Set<Friend> people, String source) where people is the representation of the friend graph and source is the id of a Friend. If people is null or if source cannot be found in the graph, then throw an IllegalArgumentException. 3.2.2 Dijkstra.java 55pts Dijkstra’s algorithm is essentially an extension of breadth-first search for weighted graphs. It produces the shortest path between given source and destination nodes in a directed graph with non-negative edge weights. Pseudocode for Dijkstra’s algorithm is given in page 655 of your text- book. The algorithm relies on a priority queue that orders nodes in the graph by their distance from the source node. You may use the java PriorityQueue class in your implementation of the algo- rithm. The type of the elements in a PriorityQueue must implement the Comparable interface; we suggest creating an inner class in Dijkstra.java that extends the Friend class and (by default, since it is a subclass of Friend) implements Comparable. For example: class ExtFriend extends Friend { ...
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}