Question: Can someone Help me how do I start this? Here is my code for above assignment hope that helps. import java.util.ArrayList; import java.lang.String; import bridges.base.Element;

 Can someone Help me how do I start this? Here ismy code for above assignment hope that helps. import java.util.ArrayList; import java.lang.String;

Can someone Help me how do I start this?

Here is my code for above assignment hope that helps.

import java.util.ArrayList;

import java.lang.String;

import bridges.base.Element;

import bridges.base.SLelement;

import bridges.base.GraphAdjList;

import bridges.base.Edge;

import bridges.connect.Bridges;

import bridges.data_src_dependent.EarthquakeUSGS;

import bridges.data_src_dependent.USGSaccount;

public class earthquake_graph {

protected static String COLOR_HIGHLIGHT = "blue";

protected static String COLOR_DEFAULT = "green";

protected static String COLOR_ENDS = "red";

public static void main(String[] args) throws Exception {

// initialize Bridges

// parameters are assignment number, app key, user id

int num_quakes = 1000;

USGSaccount acct = new USGSaccount (" earthquake")

list eq_list = getEarthQuakeUSGSData(acct, num_quakes);

Bridges bridges = new Bridges(11,

"your bridge key", "your username");

// set a title for the visualization

bridges.setTitle("A Simple Graph Example using USGS Earthquake dataset");

// get the Earthquake USGS data

USGSaccount acct = new USGSaccount ("earthquake") ;

ArrayList eq_list =

(ArrayList) bridges.getEarthquakeUSGSData(acct, 1000);

// create an adjacency list based graph

GraphAdjList g = new GraphAdjList();

// first create vertices for six nodes and

// add them to the graph

String a1 = "Magn 0-1.0", a2 = "Magn 1.0-2.0",a3 = "Magn 3.0-4.0",

a4 ="Magn 4.0-5.0", a5 ="Magn 5.0-6.0", a6 ="Magn >6.0";

g.addVertex(a1, ""); g.addVertex(a2, ""); g.addVertex(a3, ""); g.addVertex(a4, "");

g.addVertex(a5, ""); g.addVertex(a6, "");

// add an edge between the six nodes

// the third parameter is the edge weight

g.addEdge(a1, a2, 1);//mag

g.addEdge(a2, a3, 1);//mag 1 to 2

g.addEdge(a3, a4, 1);//mag 3 to 4

g.addEdge(a4, a5, 1);//mag 4 to 5

g.addEdge(a5, a6, 1);//mag 5 to 6

g.addEdge(a6, a1, 1);//mag >6

// color the two actor nodes

// get their nodes

Element v1 = g.getVertices().get(a1);

Element v2 = g.getVertices().get(a2);

// we will find the first 15 immediate neighbors of

// of the two actors and color those links and nodes

// by following their adjacency lists

for (int k = 0; k

// from the actor movie data, get an actor-movie pair

double m = eq_list.get(k).getMagnitude();

String l = eq_list.get(k).getLocation();

String t = eq_list.get(k).getTime();

if(m

String i = "m,l,t";

g.addVertex(i, "");

g.addEdge(a1, i, 1);

// assign to specific node and give specific color / opacity / size

g.getVertices().get("m,l,t").getVisualizer().setSize(50);

g.getVertices().get("m,l,t").getVisualizer().setOpacity(.1f);

g.getVertices().get("m,l,t").getVisualizer().setColor(250,0,0,1);

}

else if(m > 1.0 && m

String n = "n";

g.addVertex(n, "");

g.addEdge(a2, n, 1);

//assign to specific node and give specific color / opacity / size

g.getVertices().get("Magn 1.0-2.0").getVisualizer().setSize(40);

g.getVertices().get("Magn 1.0-2.0").getVisualizer().setOpacity(.3f);

g.getVertices().get("Magn 1.0-2.0").getVisualizer().setColor(255,0,0,1);

}

else if(m > 3.0 && m

g.getVertices().get("Magn 3.0-4.0").getVisualizer().setSize(30);

g.getVertices().get("Magn 3.0-4.0").getVisualizer().setOpacity(.5f);

g.getVertices().get("Magn 3.0-4.0").getVisualizer().setColor(255,0,0,1);

}

}

// we will next color all the nodes emanating

// get the adjacency list first

SLelement> head =

g.getAdjacencyList().get("Magn 0-1.0");

// traverse the adjacency list

for (SLelement> sle = head; sle != null;

sle = sle.getNext() ) {

// get the terminating vertex

String term_vertex = sle.getValue().getVertex();

// find the corresponding element

Element el = g.getVertices().get(term_vertex);

// set the color of the node

if (!term_vertex.equals("Magn 1.0-2.0"))

el.getVisualizer().setColor("green");

}

bridges.setDataStructure(g);

bridges.visualize();

}}

This project will use USGS earthquake dataset to cluster quakes by magnitude, and demonstrate a number of graph algorithms, and computing metrics based on the graph structure This project will be in 2 parts and will use BRIDGES for visualizing the required output of each task. In part 1 (this project), you will read in the given dataset and display the graph using an adjacency list representation. You will also cluster the retrieved qu data by magnitude. Priort to starting the project, Dataset: We will use the USGS earthquake dataset for this project; similar to the IMDB dataset, a call to get the earthquake data is as follows (you will need to import the two classes, USGSaccount and Earthquake USGS) and make the following calls int num-quakes 1000 USGSaccount acct new account earthquake Bridges get Earth QuakeUSGSData (acct List

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!