It is incorrect! When you corroborate with the LLM ask it to give you solution algorithms for the required sizes and speeds of run per each case!
Beginner Here - Help w/ Programming Assignment: Implementing algorithms in Graphs
What is this new Assignment Help, never heard of it?
Hi, I ran into some of the same issues mentioned here. To restart, I deleted the existing notebook but unable to find the original to begin with. Any guidance as to where to get the original notebook will be much appreciated.
Thanks,
Udhay
To restore a missing file, go to the Lab Help menu (it looks like a question-mark inside a circle). There you will find a button “Get latest version”.
I’m attempting to complete this by just LLM write the code. Stuck with the last method. What prompt can LLM fix this? I have tried multiple times but no luck. Thanks in advance!
Failed test case: Exceeded time execution limit for a tour starting in node 0. To replicate the graph, you may run generate_graph(nodes = 300, complete = True, seed = 42).
Expected: tsp_medium_graph method must run in less than 1.5 seconds
Got: Time execution exceeded 1.5 seconds
Sorry, I’m not a mentor for that course, so I’m not familiar with the materials.
My general suggestion for this assignment is: in the assignment when you collaborate with the LLM give it a role and ask it give you code for different implementations of graph sizes and mention the speed required in each case. The LLM will give you different implementations for each exercise, make sure to give it all the details as required on the task. If one method is not fast enough, try again, corroborating back and forth with the LLM to give you another implementation of such an algorithm!
I need help with the Programming assignment :Implementing algorithms in graphs week 3. I am newbee and any help is appreciated
here is my code
{mentor edit: code removed
Example usage
graph_advanced = Graph_Advanced()
Define the graph by adding edges (from_node, to_node, weight)
graph_advanced.add_edge(‘A’, ‘B’, 1)
graph_advanced.add_edge(‘A’, ‘C’, 4)
graph_advanced.add_edge(‘B’, ‘C’, 2)
graph_advanced.add_edge(‘B’, ‘D’, 5)
graph_advanced.add_edge(‘C’, ‘D’, 1)
graph_advanced.add_edge(‘D’, ‘E’, 3)
graph_advanced.add_edge(‘C’, ‘E’, 6)
Find the shortest path from node ‘A’ to node ‘E’
start_node = ‘A’
end_node = ‘E’
distance, path = graph_advanced.shortest_path(start_node, end_node)
print(f"Shortest path from {start_node} to {end_node}: Distance = {distance}, Path = {path}")
Define the complete graph by adding edges (from_node, to_node, weight)
graph_advanced.add_edge(0, 1, 1)
graph_advanced.add_edge(0, 2, 4)
graph_advanced.add_edge(0, 3, 6)
graph_advanced.add_edge(1, 2, 2)
graph_advanced.add_edge(1, 3, 5)
graph_advanced.add_edge(2, 3, 1)
graph_advanced.add_edge(1, 0, 1)
graph_advanced.add_edge(2, 0, 4)
graph_advanced.add_edge(3, 0, 6)
graph_advanced.add_edge(2, 1, 2)
graph_advanced.add_edge(3, 1, 5)
graph_advanced.add_edge(3, 2, 1)
Find the optimal TSP tour starting from node 0
distance, path = graph_advanced.tsp_small_graph()
print(f"Optimal TSP tour starting at 0: Distance = {distance}, Path = {path}")
Generate a complete graph with 1000 nodes and random weights
num_nodes = 1000
for i in range(num_nodes):
for j in range(i + 1, num_nodes):
weight = random.randint(1, 100)
graph_advanced.add_edge(i, j, weight)
graph_advanced.add_edge(j, i, weight)
Find a “pretty good” TSP tour starting from node 0
distance, path = graph_advanced.tsp_large_graph()
print(f"TSP tour starting at 0: Distance = {distance}, Path length = {len(path)}")
A reminder:
Please do not share your code on the Forum for a graded assignment. That is not allowed by the Code of Conduct.
Please just describe your issue in some detail, and include screen capture images of any error messages.
If a mentor needs to see your code, they will contact you with instructions.
Did you ask the LLM to give you different implementation options (based on each exercise’s requirements)? If so, what was the name of the algorithms it gave you and you implemented in the examples?
Hi @kic can you please help me why i am getting error with Failed test case: shortest_path returned an exception in test case. You may replicate the graph by running generate_graph(nodes = 10000, edges = 10, seed = 65).
Expected:
shortest_path must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: shortest_path returned an exception in test case. You may replicate the graph by running generate_graph(nodes = 10000, edges = 10, seed = 66).
Expected:
shortest_path must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: shortest_path returned an exception in test case. You may replicate the graph by running generate_graph(nodes = 10000, edges = 10, seed = 67).
Expected:
shortest_path must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object. Failed test case: tsp_small_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 10, complete = True, seed = 65).
Expected:
tsp_small_graph must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_small_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 10, complete = True, seed = 66).
Expected:
tsp_small_graph must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_small_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 10, complete = True, seed = 67).
Expected:
tsp_small_graph must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object. Failed test case: tsp_large_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 1000, complete = True, seed = 65).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_large_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 1000, complete = True, seed = 66).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_large_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 1000, complete = True, seed = 67).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object. Failed test case: tsp_medium_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 300, complete = True, seed = 65).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_medium_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 300, complete = True, seed = 66).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object.
Failed test case: tsp_medium_graph returned an exception in test case. You may replicate the graph by generate_graph(nodes = 300, complete = True, seed = 67).
Expected:
{function_name} must run without exceptions,
but got:
Exception thrown is: cannot unpack non-iterable int object. can you please help me or can you please guide me:-- swarnendu.qlik@gmail.com
This type or error means you are not outputting a list as it is probably required by the grader! Check what are is function’s output?
Also since you are using the LLM why don’t you feed it this error and get its feedback? That is part of the the work process too, when pairing up with an LLM!