, , ,

[SOLVED] Cse2050 hw 11: graph implementations

$25

File Name: Cse2050_hw_11__graph_implementations.zip
File Size: 339.12 KB

5/5 - (1 vote)

Complete HW5 by implementing the circular puzzle in a Graph ADT.

def list_to_graph(L):

vertices = set(range(1, len(L) + 1))

edges = set()

 

for i in range(len(L)):

weight = L[i]

next_index = (i + weight) % len(L)

 

edges.add((i + 1, next_index + 1, weight))

edges.add((next_index + 1, i + 1, weight))

 

return vertices, edges

 

Submit

Shopping Cart
[SOLVED] Cse2050 hw 11: graph implementations[SOLVED] Cse2050 hw 11: graph implementations
$25