B1 Write a function NearestPoint (G,v,mylist) which takes as input a networkx object G representing a weighted graph, an object v which will be a node of G, and a list mylist of some other nodes of G. The function should return whichever node in mylist is nearest to v (in the sense of the minimum weight path from v). In the event of a tie, it should return the nearest node which appears earliest in mylist. CORDELIA WEBB UNIVERSITY OF LEEDS, 2023/24 B2 We say that a weighted graph has the Unique Weight Prop- erty (UWP) if no two edges have the same weight. Recall from Workshop 9-10 that if G is connected and has the UWP then it will automatically have a unique spanning tree. Write a func- tion UWP (G) which tests whether or not G has the UWP and returns True or False accordingly. Hint: extract a list of edge-weights and use the count func- tion to see how many times each appears. B3 Write a function GoodPath (G,a,b) which takes as input a net- workx object G representing a connected weighted graph with UWP and objects a, b which will be nodes of G. Your function should return True if the shortest path from a to b lies entirely inside the unique minimal connector and False otherwise.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
B1 Write a function NearestPoint (G,v,mylist) which takes as
input a networkx object G representing a weighted graph, an
object v which will be a node of G, and a list mylist of some
other nodes of G. The function should return whichever node
in mylist is nearest to v (in the sense of the minimum weight
path from v). In the event of a tie, it should return the nearest
node which appears earliest in mylist.
CORDELIA WEBB UNIVERSITY OF LEEDS, 2023/24
B2 We say that a weighted graph has the Unique Weight Prop-
erty (UWP) if no two edges have the same weight. Recall from
Workshop 9-10 that if G is connected and has the UWP then it
will automatically have a unique spanning tree. Write a func-
tion UWP (G) which tests whether or not G has the UWP and
returns True or False accordingly.
Hint: extract a list of edge-weights and use the count func-
tion to see how many times each appears.
B3 Write a function GoodPath (G,a,b) which takes as input a net-
workx object G representing a connected weighted graph with
UWP and objects a, b which will be nodes of G. Your function
should return True if the shortest path from a to b lies entirely
inside the unique minimal connector and False otherwise.
Transcribed Image Text:B1 Write a function NearestPoint (G,v,mylist) which takes as input a networkx object G representing a weighted graph, an object v which will be a node of G, and a list mylist of some other nodes of G. The function should return whichever node in mylist is nearest to v (in the sense of the minimum weight path from v). In the event of a tie, it should return the nearest node which appears earliest in mylist. CORDELIA WEBB UNIVERSITY OF LEEDS, 2023/24 B2 We say that a weighted graph has the Unique Weight Prop- erty (UWP) if no two edges have the same weight. Recall from Workshop 9-10 that if G is connected and has the UWP then it will automatically have a unique spanning tree. Write a func- tion UWP (G) which tests whether or not G has the UWP and returns True or False accordingly. Hint: extract a list of edge-weights and use the count func- tion to see how many times each appears. B3 Write a function GoodPath (G,a,b) which takes as input a net- workx object G representing a connected weighted graph with UWP and objects a, b which will be nodes of G. Your function should return True if the shortest path from a to b lies entirely inside the unique minimal connector and False otherwise.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning