2. Understanddefault_graphtheory_linearalg_svgPartial; With NegativeEasyD1 function process%QUESTION.NUMBER%(QNo) { if ( document.forms.name != "FEEDBACK" ) { QT = QuestionText%QUESTION.NUMBER% SVGG = SVG_graph%QUESTION.NUMBER% + "

" ET = EquationText%QUESTION.NUMBER% COR = Correct%QUESTION.NUMBER% //alert(SVG_plot%QUESTION.NUMBER%) Nwidth=getFontSize()/16*310 Nheight=getFontSize()/16*80 a1="" Nwidth=getFontSize()/16*30 Nheight=getFontSize()/16*80 SHOW= COR; ANS= "
To find the corresponding adjacency matrix, you should look carefully at every edge to see if it exists in the given graph (or multi-graph). If the graph is undirected, and hence is symmetric (i.e. for 1in and for 1jn, Ai,j = Aj,i) you should only look at the upper triangular or the lower triangular part of the matrices (so that it can save you time when answering this question).

By implementing these procedures properly, the answer you should obtain is:

"; for ( var i=5; iNone of these!" ) {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+ " was correct. The actual answer is "+Answer%QUESTION.NUMBER%+".
"} else {document.forms.elements[item+3].value = "Your answer "+document.forms.elements[item].value+" was correct.
"} } else { if (document.forms.elements[item].value==Distractor1%QUESTION.NUMBER%) {document.forms.elements[item+3].value= "1). Your answer "+document.forms.elements[item].value+" should have been "+COR+"
"+ANS+"
"+SHOW+"
" } else { if (document.forms.elements[item].value==Distractor2%QUESTION.NUMBER%) {document.forms.elements[item+3].value= "2). Your answer "+document.forms.elements[item].value+" should have been "+COR+"
"+ANS+"
"+SHOW+"
" } else { if (document.forms.elements[item].value==Distractor3%QUESTION.NUMBER%) {document.forms.elements[item+3].value= "3). Your answer "+document.forms.elements[item].value+" should have been "+COR+"
"+ANS+"
"+SHOW+"
" } else { if (document.forms.elements[item].value==Distractor4%QUESTION.NUMBER%) {document.forms.elements[item+3].value= "4). Your answer "+document.forms.elements[item].value+" should have been "+COR+"
"+ANS+"
"+SHOW+"
" } else { if (document.forms.elements[item].value=="None of these!") {document.forms.elements[item+3].value= "5). Your answer "+document.forms.elements[item].value+" should have been "+COR+"
"+ANS+"
"+SHOW+"
" } else { if (document.forms.elements[item].value=="I don't know!") {document.forms.elements[item+3].value= "6). You did not know! The answer should have been "+COR+"
"+ANS+"
"+SHOW+"
" } } } } } } } } } } document.forms.elements[item+3].value = QT + SVGG + ET + document.forms.elements[item+3].value } Choice%QUESTION.NUMBER% = new Array(4) function question%QUESTION.NUMBER%() { labels = new Array(); n = displayarray(1,4,9,0); pick = Math.round((Math.random()*(n-1))+1); u = Math.round(Math.random()*(n/5)+1); v = u+Math.round(Math.random()*(n/5) + 1); QuestionText%QUESTION.NUMBER% = ""+personname()+" is given the following graph with double edges shown in red for clarity.

" //CORRECT ANSWER = A A = getrandommatrix(n, n, 0, 2, 1); // A has to have 0 or 2's down the diagonal - not all 0's so A[pick][pick] = 1; for (i = 1; i <= n; i++){ if(A[i][i] >= 1){A[i][i] = 2; } } for (i = 1; i <= n; i++){ labels[i]=alphabet(i-1,1); for(j = i; j <= n; j++){ A[i][j] = A[j][i]; } } //DISTRACTOR D1: Forgetting about possibility of having 2's on loops and edges connecting a pair of vertices D1 = getrandommatrix(n, n, 0, 2, 1); // D1 has to have 0 or 2's down the diagonal for (i = 1; i <= n; i++){ for (j = 1; j <= n; j++){ D1[i][j] = A[i][j]; if(D1[i][j] ==2){D1[i][j]=1}; } } //DISTRACTOR D2: 1's in the diagonal D2 = getrandommatrix(n, n, 0, 2, 1); for (i = 1; i <= n; i++){ for (j = 1; j <= n; j++){ D2[i][j] = A[i][j]; } if(D2[i][i] == 2){ D2[i][i] = 1; } } //DISTRACTOR D3: Adjustments to all values. D3 = getrandommatrix(n,n,0,2,1); for(i = 1; i <= n; i++){ for(j = 1; j <= n; j++){ if(A[i][j] == 0){ D3[i][j] = (A[i][j]-0) + 1; }else if(A[i][j] == 1){ D3[i][j] = (A[i][j]-0) + 2; }else if(A[i][j] == 2){ D3[i][j] = (A[i][j]-0)*0; } } } //DISTRACTOR D4: Asymmetric matrix D4 = getrandommatrix(n, n, 0, 2, 1); for (i = 1; i <= n; i++){ for (j = 1; j <= n; j++){ D4[i][j] = A[i][j]; } } //now change an off-diagonal element in upper matrix pick1= Math.ceil(Math.random()*(n-1)); pick2= Math.ceil(Math.random()*(n-pick1))+pick1; D4[pick1][pick2] = (D4[pick1][pick2]-0)+1; Nwidth1 = getFontSize()/16*(n * 45) ; //Nwidth2 = getFontSize()/16*(n * 35) ; Nheight = getFontSize()/16*(n * 40) ; m1="" m2="" m3="" // n+1,n+1 in displayincidencematrix(A,labels,n+1,n+1) means no highlighting c1 = "" d1 = "

" d2 = "" d3 = "" d4 = "" EquationText%QUESTION.NUMBER% = "
Find the adjacency matrix representing the above graph.
" ratio_along_line = 0.; // places arrow on line: if 0 then no arrow is drawn. // ratio_along_line = 0; filled = 1; // = 1 filled arrow else open double_path_colour = "red"; // double_path_colour = getFgColor(); double_path_skinnyness = 10; fx = getFontSize()/16; size1 = fx*400; size2 = fx*400; size3 = fx*(100*fx*fx+420*fx+185); size4 = fx*(100*fx*fx+420*fx+185); svg_start = ''; SVG_graph%QUESTION.NUMBER% = SVG_digraph(A,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start) + "

" Correct%QUESTION.NUMBER% = m1 + m2 + m3 + c1+"

"; // the distractors all have to be different for marking to work (as usual) ... hence + "d1" etc Distractor1%QUESTION.NUMBER% = m1 + m2 + m3 + d1+"
"; Distractor2%QUESTION.NUMBER% = m1 + m2 + m3 + d2+"
"; Distractor3%QUESTION.NUMBER% = m1 + m2 + m3 + d3+"
"; Distractor4%QUESTION.NUMBER% = m1 + m2 + m3 + d4+"
"; randomisation = displayarray(3,1,3,0); randomisation2 = displayarray(4,0,3,1); WhichDistractor = new Array(4); WhichDistractor = Distractor1%QUESTION.NUMBER% WhichDistractor = Distractor2%QUESTION.NUMBER% WhichDistractor = Distractor3%QUESTION.NUMBER% WhichDistractor = Distractor4%QUESTION.NUMBER% NOT = Math.ceil(4*Math.random()); xxx = Math.ceil(4*Math.random()); if ( NOT==1 ) { Answer%QUESTION.NUMBER% = Correct%QUESTION.NUMBER% Correct%QUESTION.NUMBER% = "None of these!" Choice%QUESTION.NUMBER%[xxx] = WhichDistractor[randomisation2]; } else { Choice%QUESTION.NUMBER%[xxx] = Correct%QUESTION.NUMBER% } Choice%QUESTION.NUMBER%[xxx+randomisation] = WhichDistractor[randomisation2]; Choice%QUESTION.NUMBER%[xxx+randomisation] = WhichDistractor[randomisation2]; Choice%QUESTION.NUMBER%[xxx+randomisation] = WhichDistractor[randomisation2]; for ( var yyy=xxx; yyy<=xxx+3; yyy++ ) { if ( yyy>4 ) { Choice%QUESTION.NUMBER%[yyy-4] = Choice%QUESTION.NUMBER%[yyy] } } if ( NOT==1 ) { Choice%QUESTION.NUMBER% = Correct%QUESTION.NUMBER% Choice%QUESTION.NUMBER% = "I don't know!" } else { Choice%QUESTION.NUMBER% = "None of these!" Choice%QUESTION.NUMBER% = "I don't know!" } radio = "" for ( i=1; i<7; i++ ) { if ( i==1 ) {document.write(QuestionText%QUESTION.NUMBER% + SVG_graph%QUESTION.NUMBER%+EquationText%QUESTION.NUMBER%+"

" + radio + Choice%QUESTION.NUMBER%[i] + "
")} else {document.write(radio + Choice%QUESTION.NUMBER%[i] + "
")} } document.write('') document.write('') } if ( document.forms.name == "FEEDBACK" ) {} else {question%QUESTION.NUMBER%()} ]]> "0" INCLUDES NOCASE "Correct"Your answer is correct.]]> "0" INCLUDES NOCASE "1)."Your answer is incorrect.
You have the right idea, but you failed to realise that loops are represented by 2's in the diagonal as well as that more than one edge can connect the same pair of vertices, which would enable 2's to appear in the incidence matrix.]]>
"0" INCLUDES NOCASE "2)."Your answer is incorrect.
You have the right idea, but notice that for each loop connecting one vertex to itself, it is the same edge that is creating the loop. Therefore, there should be 2's instead of 1's in the diagonal of the incidence matrix.]]>
"0" INCLUDES NOCASE "3)."Your answer is incorrect.
This incidence matrix has no real connection to the graph displayed. It is assumed that you simply tried to guess the answer to the question and therefore, you have a negative score for this question.]]>
"0" INCLUDES NOCASE "4)."Your answer is incorrect.
Notice that the graph in question is symmetric, especially as there are no arrows to denote a digraph. The answer you selected, however, is not symmetric..]]>
"0" INCLUDES NOCASE "5)."Your answer None of these was incorrect.
Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a tutor.]]>
"0" INCLUDES NOCASE "6)."You answered Did Not Know.
Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a tutor.]]>
OTHERYou didn't select any of the options!
Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a tutor.]]>
if (document.forms.name == "FEEDBACK") { Count = document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } ]]>
5. Evaluatedefault_graphtheory_linearalg_svgAll or NoneIntermediateD1 function process%QUESTION.NUMBER%(QNo) { QT1=QuestionText1%QUESTION.NUMBER% QT2=QuestionText2%QUESTION.NUMBER% ET1%QUESTION.NUMBER%=EquationText1%QUESTION.NUMBER% COR=Correct%QUESTION.NUMBER% DISA=Distractor1%QUESTION.NUMBER% DISB=Distractor2%QUESTION.NUMBER% DISC=Distractor3%QUESTION.NUMBER% nwidth=getFontSize()/16*270 nheight=getFontSize()/16*50 a1="" a2="" a3="" //feedback ANS= "
Answering this question requires a lot of careful observation, especially if you cannot find the answer immediately. Simply look at each value in the adjacency matrix, noting the direction of the line segment in each case. Once you have found a value that does not correspond to the digraph, you have found your answer. However, remember to input your answer correctly. For instance, position ("+hi+","+bye+") in the adjacency matrix is a segment "+alphabet(hi-1,1)+""+alphabet(bye-1,1)+" and position ("+bye+","+hi+") in the adjacency matrix is a segment "+alphabet(bye-1,1)+""+alphabet(hi-1,1)+".

To help you further, it may be best to write down the adjacency matrix on the paper and then, as you look at the digraph, double check all values crossing them out as you find their respective segments in the digraph.
" SHOW =""; for (var i=5; iYour answer, "+document.forms.elements[item].value+", was correct.
"} else { if (document.forms.elements[item].value==DISA) {document.forms.elements[item+3].value = "Your answer, "+document.forms.elements[item].value+", isn't correct. It should have been "+COR+".

"+ANS+"

"} else { if (document.forms.elements[item].value==DISB) {document.forms.elements[item+3].value = "Your answer, "+document.forms.elements[item].value+", should have been "+COR+".

"+ANS+"

"} else { if (document.forms.elements[item].value==DISC) {document.forms.elements[item+3].value = "Your answer, "+document.forms.elements[item].value+", should have been "+COR+".

"+ANS+"

"} else {document.forms.elements[item+3].value = "Your answer, "+document.forms.elements[item].value+", should have been "+COR+".

"+ANS+"

"} }}} document.forms.elements[item+3].value = QuestionText1%QUESTION.NUMBER% + EquationText1%QUESTION.NUMBER%+svg%QUESTION.NUMBER% + QuestionText2%QUESTION.NUMBER% + document.forms.elements[item+3].value; } function question%QUESTION.NUMBER%() { n = displayarray(1,7,9,0); A = getrandommatrix(n, n, 0, 1, 1); toss = Math.round(Math.random()); // if toss = 0 A is symmetric toss = 1; for (i = 1; i <= n; i++){ for(j = 1; j <= n; j++){ if(A[i][i] > 1){A[i][i] = 0;} } } for (i = 0; i <= n; i++){ if(A[i][i] == 1){A[i][i] = 2;} } BtoA = displayarray(2,1,n,0); if(BtoA > BtoA){ A[BtoA][BtoA] = 1; A[BtoA][BtoA] = 0; }else{ A[BtoA][BtoA] = 0; A[BtoA][BtoA] = 1; } C = getrandommatrix(n,n,0,0,1); for(i = 1; i <= n; i++){ for(j = 1; j <= n; j++){ C[i][j] = (C[i][j]-0) + (A[i][j]-0); } } keypoints = new Array(2); keypoints = (displayarray(1,1,n,0)-0); keypoints = (displayarray(1,1,n,0)-0); if(A[keypoints][keypoints] == 0 && keypoints==keypoints){ C[keypoints][keypoints] = (C[keypoints][keypoints]-0) + 2; } else if(A[keypoints][keypoints] == 0 && keypoints!=keypoints){ C[keypoints][keypoints] = (C[keypoints][keypoints]-0) + 1; } else{ C[keypoints][keypoints] = (C[keypoints][keypoints]-0)*0; } labels = new Array(); for (i = 1; i <= n; i++){ labels[i]=alphabet(i-1,1); for(j = 1; j <= n; j++){ if(toss == 0){ A[i][j] = A[j][i]; } } } hi = Math.round((Math.random()*(n-2))+1); bye = Math.round((Math.random()*(n-2))+1); if(hi == bye){bye++} A[hi][bye] != 0; Nwidth1 = getFontSize()/16*(n * 45) ; Nheight = getFontSize()/16*(n * 50) ; m1="" m2="" m3="" M1%QUESTION.NUMBER%="" M2%QUESTION.NUMBER%="
" QuestionText1%QUESTION.NUMBER% = "Consider the following adjacency matrix and the digraph:
" QuestionText2%QUESTION.NUMBER% = "The given adjacency matrix has a mistake in it and does not match the digraph shown.

Please input the edge of the digraph that is missing or added in the adjacency matrix .
For example, if you think the problem occurs at the highlighted position a"+hi+","+bye+" then enter your answer as "+alphabet(hi-1,1)+""+alphabet(bye-1,1)+".

"; QuestionText3%QUESTION.NUMBER% = " " EquationText1%QUESTION.NUMBER%=m1+m2+m3+M2%QUESTION.NUMBER%+"
"; //EquationText1%QUESTION.NUMBER% = ""; //just graph displayed if(toss == 0){ratio_along_line = 0.0;}else{ratio_along_line = 0.25; } // places arrow on line: if 0 then no arrow is drawn. filled = 1; // = 1 filled arrow else open double_path_colour = "red"; double_path_skinnyness = 10; svg%QUESTION.NUMBER% = SVG_digraph(A,ratio_along_line,filled,double_path_colour,double_path_skinnyness) + "
" Correct%QUESTION.NUMBER% = ""; Correct%QUESTION.NUMBER% += alphabet(keypoints-1,1)+alphabet(keypoints-1,1); Distractor1%QUESTION.NUMBER% = ""; if(keypoints != keypoints){ Distractor1%QUESTION.NUMBER% += alphabet(keypoints-1,1)+alphabet(keypoints-1,1); } Distractor2%QUESTION.NUMBER% = ""; for (ivertex = 1; ivertex <=n; ivertex++){ for (jvertex = 1; jvertex <=n; jvertex++){ if(A[ivertex][jvertex] != 0){Distractor2%QUESTION.NUMBER% += alphabet(jvertex-1,1)+alphabet(ivertex-1,1)+","} }} Distractor3%QUESTION.NUMBER% = ""; strlength = Correct%QUESTION.NUMBER%.length; //Correct%QUESTION.NUMBER% = Correct%QUESTION.NUMBER%.substring(0,strlength-1); // removes last comma required_input_string_length%QUESTION.NUMBER%=Correct%QUESTION.NUMBER%.length; // includes all the commas. //numbers_string=""; //for (i_input = 0; i_input < Alist.length; i_input++){ //numbers_string +=Alist[i_input].toString();} //required_input_string_length%QUESTION.NUMBER% += numbers_string.length; document.write(QuestionText1%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%); document.write(svg%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER% + QuestionText3%QUESTION.NUMBER%); document.write("") document.write("") } if (document.forms.name=="FEEDBACK") {} else {question%QUESTION.NUMBER%()} ]]> "Choice" INCLUDES NOCASE "was Correct"Well done! "Choice" INCLUDES NOCASE "ought to have been"Write down the question and ask a teacher how to do it.]]> "Choice" INCLUDES NOCASE "isn't correct"You have entered the correct answer in backwards, thus giving the wrong directed edge. Please remember how directed edges work in adjacency matrices. "Choice" INCLUDES NOCASE "is incorrect"NO NO NO! "Choice" INCLUDES NOCASE "was wrong"You should attempt this question. OTHER if (document.forms.name=="FEEDBACK") { Count=document.forms.elements.length document.write(document.forms.elements[Count-1].value) var titleofpopup = "Related material"; var help = wheretolook("%QUESTION.TAGS%","%QUESTION.TOPIC%"); document.write("

"+""+"
") } // Template updated and developed by Daniel Nichols & Martin Greenhow, Brunel University, July 2004, working // on original templates authored by Dominic Smith of Brunel University, July 2001, with // valuable contributions from Professor David Hewitt of Monash University, Australia. ]]>