// Numbas version: exam_results_page_options {"name": "Find the shortest path", "extensions": [], "custom_part_types": [], "resources": [["question-resources/network2_P9Gdj38.svg", "/srv/numbas/media/question-resources/network2_P9Gdj38.svg"]], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Find the shortest path", "tags": [], "metadata": {"description": "
Students are shown a graph with 6 vertices and asked to find the length of the shortest path from A to a random vertex.
\nThere is only one graph, but all of the weights are randomised.
\nThey can find the length any way they wish. In the advice, the steps of Dijkstra's algorithm used in solving this problem are displayed. It is not a complete worked solution but it should be sufficient to figure out the shortest path used to reach each vertex.
", "licence": "All rights reserved"}, "statement": "Consider the following network:
\n", "advice": "You can either work out the shortest path by looking at the graph and figuring it out, or by using Dijkstra's algorithm.
\nThe length of the shortest path is calculated by adding up the weights along the shortest path.
\n\nThe computer used Dijkstra's algorithm to find a shortest path.
\nHere are the shortest distances from A to each vertex that it calculated in each step of the algorithm. You can use this to help you find the shortest path.
\nA blank entry means that the algorithm has not yet added that vertex to the shortest path tree.
\nStep No | \nA | \nB | \nC | \nD | \nE | \nF | \n
1 | \n0 | \n{if(distarray[0][1]=99,\"\",distarray[0][1])} | \n{if(distarray[0][2]=99,\"\",distarray[0][2])} | \n{if(distarray[0][3]=99,\"\",distarray[0][3])} | \n{if(distarray[0][4]=99,\"\",distarray[0][4])} | \n{if(distarray[0][5]=99,\"\",distarray[0][5])} | \n
2 | \n0 | \n{if(distarray[1][1]=99,\"\",distarray[1][1])} | \n{if(distarray[1][2]=99,\"\",distarray[1][2])} | \n{if(distarray[1][3]=99,\"\",distarray[1][3])} | \n{if(distarray[1][4]=99,\"\",distarray[1][4])} | \n{if(distarray[1][5]=99,\"\",distarray[1][5])} | \n
3 | \n0 | \n{if(distarray[2][1]=99,\"\",distarray[2][1])} | \n{if(distarray[2][2]=99,\"\",distarray[2][2])} | \n{if(distarray[2][3]=99,\"\",distarray[2][3])} | \n{if(distarray[2][4]=99,\"\",distarray[2][4])} | \n{if(distarray[2][5]=99,\"\",distarray[2][5])} | \n
4 | \n0 | \n{if(distarray[3][1]=99,\"\",distarray[3][1])} | \n{if(distarray[3][2]=99,\"\",distarray[3][2])} | \n{if(distarray[3][3]=99,\"\",distarray[3][3])} | \n{if(distarray[3][4]=99,\"\",distarray[3][4])} | \n{if(distarray[3][5]=99,\"\",distarray[3][5])} | \n
5 | \n0 | \n{if(distarray[4][1]=99,\"\",distarray[4][1])} | \n{if(distarray[4][2]=99,\"\",distarray[4][2])} | \n{if(distarray[4][3]=99,\"\",distarray[4][3])} | \n{if(distarray[4][4]=99,\"\",distarray[4][4])} | \n{if(distarray[4][5]=99,\"\",distarray[4][5])} | \n
6 | \n0 | \n{if(distarray[5][1]=99,\"\",distarray[5][1])} | \n{if(distarray[5][2]=99,\"\",distarray[5][2])} | \n{if(distarray[5][3]=99,\"\",distarray[5][3])} | \n{if(distarray[5][4]=99,\"\",distarray[5][4])} | \n{if(distarray[5][5]=99,\"\",distarray[5][5])} | \n