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

Can someone Help me how do I start this? Here is my code for above assignment ho

ID: 3803890 • Letter: C

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;

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<EarthquakeUSGS> eq_list = getEarthQuakeUSGSData(acct, num_quakes);

       Bridges<String, String> bridges = new Bridges<String, String>(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<EarthquakeUSGS> eq_list =

       (ArrayList<EarthquakeUSGS>)   bridges.getEarthquakeUSGSData(acct, 1000);

                   // create an adjacency list based graph

   GraphAdjList<String, String> 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 <1

   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<String> v1 = g.getVertices().get(a1);

   Element<String> 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 < eq_list.size(); 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 < 1.0){

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 < 2.0){

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< 4.0){

   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<Edge<String>> head =

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

                   // traverse the adjacency list

   for (SLelement<Edge<String>> sle = head; sle != null;

                               sle = sle.getNext() ) {

                   // get the terminating vertex

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

                   // find the corresponding element

       Element<String> 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

Explanation / Answer

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<EarthquakeUSGS> eq_list = getEarthQuakeUSGSData(acct, num_quakes);

       Bridges<String, String> bridges = new Bridges<String, String>(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<EarthquakeUSGS> eq_list =

       (ArrayList<EarthquakeUSGS>)   bridges.getEarthquakeUSGSData(acct, 1000);

                   // create an adjacency list based graph

   GraphAdjList<String, String> 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 <1

   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<String> v1 = g.getVertices().get(a1);

   Element<String> 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 < eq_list.size(); 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 < 1.0){

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 < 2.0){

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< 4.0){

   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<Edge<String>> head =

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

                   // traverse the adjacency list

   for (SLelement<Edge<String>> sle = head; sle != null;

                               sle = sle.getNext() ) {

                   // get the terminating vertex

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

                   // find the corresponding element

       Element<String> 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();

}}