Project 2 22 C 021 Computer Science II

  • Slides: 12
Download presentation
Project 2 22 C: 021 Computer Science II : Data Structures

Project 2 22 C: 021 Computer Science II : Data Structures

Power-law Distribution The power-law degree distribution captures the phenomena that a small number of

Power-law Distribution The power-law degree distribution captures the phenomena that a small number of vertices in a graph have high degree, whereas most of the vertices have very small degree Captures phenomenon prevalent in real networks

Requirements Run 3 experiments Capture results from experiments and prepare a deliverable Details on

Requirements Run 3 experiments Capture results from experiments and prepare a deliverable Details on deliverables will be up soon.

Experiment 1 Run experiments to support the hypothesis: “random graphs generated in Project 1

Experiment 1 Run experiments to support the hypothesis: “random graphs generated in Project 1 do not satisfy the power-law distribution” Write a method int [] degree. Distribution () This method returns the distribution such that element i holds the number of vertices with degree i. Use results to determine if the hypothesis holds.

Experiment 2 Implement a graph similar to one from Project 1 Randomly generate graph

Experiment 2 Implement a graph similar to one from Project 1 Randomly generate graph Instead of random rewiring use preferential rewiring. Project description explains these terms well Repeat tests from Experiment 1 on this new graph Determine if this new graph generation mechanism supports power-law distribution

How do I determine probabilities? Experiment 2 expects you to wire vertices depending on

How do I determine probabilities? Experiment 2 expects you to wire vertices depending on how “popular” they are. Popularity is defined as the degree of a vertex Higher the degree, the more popular a vertex is You connect to vertices depending on their degree (preferential rewiring) This is different from Project 1, where a random non-neighbor was chosen to replace an edge (uniform rewiring)

How do I determine probabilities? Determine a set Z that contains all nonneighbors of

How do I determine probabilities? Determine a set Z that contains all nonneighbors of v v is the vertex you're trying to wire For each z in Z compute probability of that vertex being picked as prob. Z [i] = (degree (Z[0]) + degree (Z[1]). . . +degree(Z[i])) / D D is the sum of all degrees of vertices in Z

How do I determine probabilities? Now, generate a random real number in the range

How do I determine probabilities? Now, generate a random real number in the range 0 to 1 Find the first i such that p ≤ prob. Z[i] Note that prob. Z is a non-decreasing seires. Connect to Z[i]

Experiment 3 What are we trying to determine? Can verticies in our models use

Experiment 3 What are we trying to determine? Can verticies in our models use “local information” to connect to a different vertex Run experiments on both Uniform rewiring Preferential rewiring This experiment is not difficult to figure See project description on the course webpage.

Finding distances between vertices Use greedy algorithm to find distance between two vertices (in

Finding distances between vertices Use greedy algorithm to find distance between two vertices (in hops) On a vertex v find a vertex w that is closer to destination than v is, and use w as the next hop “Closer”: Remember: coordinates of each vertex are available in graph Use breadth-first-search to determine shortest path hop distance Use Dijkstra's shortest path algorithm to determine the shortest path Euclidean-distance

Dijkstra's shortest path algorithm S <- emptyset d[v] <- infinity for all v in

Dijkstra's shortest path algorithm S <- emptyset d[v] <- infinity for all v in V d[s] <- 0 initialize the binary heap H to V while(H is non-empty)do { v <- delete. Min(H) S <- S union v for(each u, neighbor of v)do { if(d[u] > d[v] + w(u, v)) { d[u] <- d[v] + w(u, v) change. Priority(H, u, d[u]) } } }

Dijkstra's shortest path algorithm change. Priority() will run in O(logn) But. . . Provided

Dijkstra's shortest path algorithm change. Priority() will run in O(logn) But. . . Provided that we know where u is within H Since H is an array this might take O(n) time O(n) is not good One approach to fix this: Have each node store its index in H When change. Priority() gets u, it can fetch u. heap. Position Make sure you update u. heap. Position whenever you perform a heap operation