// Numbas version: exam_results_page_options {"name": "Graphs: Match adjacency matrix to a graph", "extensions": ["graph-theory-v1"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Graphs: Match adjacency matrix to a graph", "tags": [], "metadata": {"description": "

Alternative version of Graphs: Match graph to its adjacency matrix, where the student must match an adjacency matrix to a graph.

", "licence": "Creative Commons Attribution 4.0 International"}, "statement": "

Consider the {number_of_graphs} graphs drawn below, each with vertices labelled from $1$ to $\\var{n+1}$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Graph $G_1$:Graph $G_2$:Graph $G_3$:
{graphs[0]}{graphs[1]}{graphs[2]}
\n

You will be shown an adjacency matrix below. The $i$th row or column of the matrix corresponds to vertex labelled $i$.

\n

Match the matrix to the graph it describes the adjacency of.

", "advice": "

The adjacency matrix $M$ of a graph $G$ has $(i,j)$th entry $1$ whenever there is an edge from vertex $i$ to vertex $j$.

\n

The $(i,j)$th entry is $0$ otherwise.

", "rulesets": {}, "extensions": ["graph-theory-v1"], "builtin_constants": {"e": true, "pi,\u03c0": true, "i": true}, "constants": [], "variables": {"graphs": {"name": "graphs", "group": "Ungrouped variables", "definition": "map(\n draw_graph_from_adjacency(matrices[q], map(string(i), i, 1..n+1)), \n q, 0..number_of_graphs - 1\n)", "description": "

Graphs built fron the adjacency matrices

", "templateType": "anything", "can_override": false}, "matrices": {"name": "matrices", "group": "Ungrouped variables", "definition": "map(\n matrix(reorder( \n [reorder(a[q][0], vertex_perm)] +\n map(\n reorder(map(a[q][i][j-i], i, 0..j-1) + a[q][j], vertex_perm), j, 1..n\n ), vertex_perm\n )), q, 0..number_of_graphs - 1\n)", "description": "

The qth matrix takes entries from a[q] as its upper triangle, then duplicates this for the bottom triangle to make a symmetric matrix.

", "templateType": "anything", "can_override": false}, "n": {"name": "n", "group": "Ungrouped variables", "definition": "7", "description": "

Each graph will contain n+1 vertices

", "templateType": "anything", "can_override": false}, "a": {"name": "a", "group": "Ungrouped variables", "definition": "map(\n [first_row[q]] +\n map([0] + repeat(random(0,0,0,1,1), n-j), j, 1..n-1)\n + [[0]],\n q, 0..number_of_graphs - 1\n)", "description": "

The top-right triangle of the adjacency matrices. The bottom-left triangle will be the transpose of this, so that the matrices are symmetrical.

\n

The first rows are all distinct, so no two adjacency matrices are the same.

\n

Change the number of 0s and 1s to get a more/less dense matrix.

", "templateType": "anything", "can_override": false}, "number_of_graphs": {"name": "number_of_graphs", "group": "Ungrouped variables", "definition": "3", "description": "

The number of graphs displayed in the question. Each adjacency matrix correctly matched to its graph will score a point.

\n

This must be less than or equal to the number of vertices n+1.

", "templateType": "anything", "can_override": false}, "graph_mat_pairs": {"name": "graph_mat_pairs", "group": "Ungrouped variables", "definition": "shuffle(\n map(\n [\n 'graph': graphs[i],\n 'matrix': matrices[i],\n 'marks': 4*id(number_of_graphs)[i]\n ], i, 0..number_of_graphs - 1\n )\n)", "description": "

The graphs, matched with their adjacency matrices. The 'marks' column will form the marking matrix

", "templateType": "anything", "can_override": false}, "first_row": {"name": "first_row", "group": "Ungrouped variables", "definition": "shuffle(\n flatten(map(\n map(vector(id(n+1)[i]) + vector(id(n+1)[j]), j, i+1..n), i, 1..n)\n )\n)", "description": "

To ensure no two adjacency matrices are the same, the first row will be taken from this list.

", "templateType": "anything", "can_override": false}, "vertex_perm": {"name": "vertex_perm", "group": "Ungrouped variables", "definition": "shuffle(0..n)", "description": "

The labels of vertices will be permuted. This is so it isn't obvious that the first row of the adjacency matrices are different.

", "templateType": "anything", "can_override": false}}, "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["graphs", "matrices", "n", "a", "number_of_graphs", "graph_mat_pairs", "first_row", "vertex_perm"], "variable_groups": [], "functions": {}, "preamble": {"js": "", "css": ""}, "parts": [{"type": "1_n_2", "useCustomName": false, "customName": "", "marks": 0, "scripts": {}, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "unitTests": [], "showCorrectAnswer": true, "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "nextParts": [], "suggestGoingBack": false, "adaptiveMarkingPenalty": 0, "exploreObjective": null, "prompt": "

$A = \\var{graph_mat_pairs[0]['matrix']}$.

\n

Select which graph $A$ is the adjacency matrix for.

", "minMarks": 0, "maxMarks": 0, "shuffleChoices": false, "displayType": "radiogroup", "displayColumns": 0, "showCellAnswerState": true, "choices": ["$G_1$", "$G_2$", "$G_3$"], "matrix": "graph_mat_pairs[0]['marks']"}], "partsMode": "all", "maxMarks": 0, "objectives": [], "penalties": [], "objectiveVisibility": "always", "penaltyVisibility": "always", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Sam Mutter", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9360/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Chris Graham", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/369/"}, {"name": "Sam Mutter", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/9360/"}]}