Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project 1 : Phase 1 22C:021 CS II Data Structures.

Similar presentations


Presentation on theme: "Project 1 : Phase 1 22C:021 CS II Data Structures."— Presentation transcript:

1 Project 1 : Phase 1 22C:021 CS II Data Structures

2 Project 1 Plan Part I (for week 1) – Turn the myListGraph class into a generic class. – Implement clusteringCoefficient(v) and clusteringCoefficient() – Add an additional data member to the myListGraph class called “locations” to keep track of an array of points. – Add the constructor: myListGraph(n, d, p) to myListGraph.

3 Project 1 Plan Part II (for week 2) – Implement the methods in the myListGraph class to compute average path length. Part II (for week 3) – Run experiments, gather data, make plots, and write report.

4 Making myListGraph Generic The List class needs to be made generic to store values of type supplied by the user of class The LinkList class needs to be made generic to pass down values of correct type to Link The myListGraph class needs to be made generic to pass down values of correct type to LinkList.

5 Making myListGraph Generic Correct way of instantiating arrays of Generic types: theItems = (AnyType[]) new Object[ newCapacity ];

6 Code to Test Generic myListGraph Will soon be available on class webpage

7 Clustering Coefficient Algorithm For a vertex V with n neighbors, there exist Q = (n choose 2) = n(n – 1) / 2 total pairs Find total number of pairs of neighbors that actually have connections, call this P Compute the clustering cofficient C v for V as C v = P / Q The algorithm to find such pairs of connected nodes is similar to listTriangles from Assignment 2

8 Why do we need “locations” We need to know the locations of points within our square to find distances between them. This variable will store the location of i th vertex at index i in “locations” array. Computing distances between points – Distance = Sqrt ((x 2 - x 1 ) 2 + (y 2 - y 1 ) 2 ) Review project 1 problem to see why distances between points is important

9 Using Probability factor While generating a graph, probably factor p determines if we connect to another of our neighbors or to a non-neighbor To use this factor, generate a floating random number and compare it with p – If the generated number is less than p, connect to a non-neighbor – Otherwise, connect to your neighbor


Download ppt "Project 1 : Phase 1 22C:021 CS II Data Structures."

Similar presentations


Ads by Google