// Numbas version: finer_feedback_settings {"name": "JSXGraph: make a spanning tree", "extensions": ["jsxgraph"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "JSXGraph: make a spanning tree", "tags": [], "metadata": {"description": "
The student must make a spanning tree of the complete graph $K_5$. They can tick boxes to include or exclude edges, or toggle them by clicking on a visual representation of the graph.
", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "A spanning tree of a graph is a subset of its edges which includes every vertex but has no cycles.
\nMake a spanning tree of this graph. To include an edge in your spanning tree, tick the corresponding box below, or click on an edge in the diagram to toggle it. Excluded edges are faded out.
\n{diagram}
", "advice": "", "rulesets": {}, "extensions": ["jsxgraph"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"diagram": {"name": "diagram", "group": "Ungrouped variables", "definition": "jsxgraph(400,400,[-2,2,2,-2],\n // a circle of points\n map(\n [\n 'point',\n [cos(i*2pi/num_points), sin(i*2pi/num_points)], \n [\"id\": \"p{i}\", \"name\": vertex_names[i], \"fixed\": true]\n ],\n i,\n 0..num_points-1\n )+\n // every possible edge between the points\n map(\n [\n 'segment',\n ['p{i}','p{j}'],\n [\"id\":\"l_{i}_{j}\"],\n // when an edge is clicked, toggle its opacity \n // - this is used to represent whether the edge is included\n [\"up\": \"l_{i}_{j}.strokeopacity = 1.2 - l_{i}_{j}.strokeopacity;\"\n ]\n ],\n [i,j],\n combinations(0..num_points-1,2)\n ),\n [\"grid\": false, \"axis\": false]\n)", "description": "", "templateType": "anything", "can_override": false}, "num_points": {"name": "num_points", "group": "Ungrouped variables", "definition": "5", "description": "", "templateType": "anything", "can_override": false}, "vertex_names": {"name": "vertex_names", "group": "Ungrouped variables", "definition": "map(capitalise(letterordinal(i)),i,0..num_points-1)", "description": "", "templateType": "anything", "can_override": false}, "q": {"name": "q", "group": "Ungrouped variables", "definition": "is_spanning_tree([[false,true,true],[false,false,false],[false,false,false]])", "description": "", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["diagram", "num_points", "vertex_names", "q"], "variable_groups": [], "functions": {"is_spanning_tree": {"parameters": [["adjacency", "list"]], "type": "boolean", "language": "javascript", "definition": "var visited = {};\nvar num_visited = 0;\nvar symm = adjacency.map(function(row,i) { return row.map(function(x,j) { return i