Question: 3. Write a function compute flow(g, dist, paths) that computes the flow across all of the edges using d and n from BFS Specifically, to

 3. Write a function compute flow(g, dist, paths) that computes the

3. Write a function compute flow(g, dist, paths) that computes the flow across all of the edges using d and n from BFS Specifically, to compute the flow from node i in g. you would use your compute flow function as follows: dist, npaths bfs(g, i) low compute flow(g, dist, npaths) This function returns a dictionary in which the keys are frozensets with two elements that represent an edge in the graph and the values are the flow value for the corresponding edge. You should consider testing your function on the graph in Figure 3.20 of the book using source node A. (The graphs in the book are provided in bookgraphs. .) You should get the same results as in the figure. Failing to test this function is a bad idea, both in terms of your grade and in terms of your likely success on later problems. 4. Write a function, shortest_path_edge_ betweenness(g) that computes the shortest-path-based betweenness of all edges of graph g by summing, for each edge, the scores that the edge receives from all runs of compute flow (for every run of bfs from a different starting point, compute flow is run, thus producing for each edge n scores, if there are n nodes in the graph g). This function should return a dictionary in which the keys are frozensets with two elements that represent an edge in the graph and the values are the betweenness value for the corresponding edge This function should utilize your bfs and compute flow functions. Run it on the example in the appendix and ensure that your functions are working properly Report the results for the graph in Figure 3.20. Which edges have the highest betweenness? What does this imply about the graph

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!