"; SVG_graph1%QUESTION.NUMBER% = SVG_digraph(D1,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph2%QUESTION.NUMBER% = SVG_digraph(D2,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph3%QUESTION.NUMBER% = SVG_digraph(D3,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph4%QUESTION.NUMBER% = SVG_digraph(D4,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph5%QUESTION.NUMBER% = SVG_digraph(C,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start); Correct%QUESTION.NUMBER% = m1+m2+m3+c1+"

"; EquationText%QUESTION.NUMBER% = SVG_graph5%QUESTION.NUMBER%; 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[0] = Distractor1%QUESTION.NUMBER% WhichDistractor[1] = Distractor2%QUESTION.NUMBER% WhichDistractor[2] = Distractor3%QUESTION.NUMBER% WhichDistractor[3] = 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[3]]; } else { Choice%QUESTION.NUMBER%[xxx] = Correct%QUESTION.NUMBER% } Choice%QUESTION.NUMBER%[xxx+randomisation[0]] = WhichDistractor[randomisation2[0]]; Choice%QUESTION.NUMBER%[xxx+randomisation[1]] = WhichDistractor[randomisation2[1]]; Choice%QUESTION.NUMBER%[xxx+randomisation[2]] = WhichDistractor[randomisation2[2]]; 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%[5] = Correct%QUESTION.NUMBER% Choice%QUESTION.NUMBER%[6] = "I don't know!" } else { Choice%QUESTION.NUMBER%[5] = "None of these!" Choice%QUESTION.NUMBER%[6] = "I don't know!" } radio = "" for ( i=1; i<7; i++ ) { if ( i==1 ) {document.write(QuestionText%QUESTION.NUMBER% + EquationText%QUESTION.NUMBER%+QuestionText1%QUESTION.NUMBER%+"

" + radio + Choice%QUESTION.NUMBER%[i] + "

")}
else
{document.write(radio + Choice%QUESTION.NUMBER%[i] + "

")}
}
document.write('')
document.write('')
}
if ( document.forms[0].name == "FEEDBACK" )
{}
else
{question%QUESTION.NUMBER%()}
]]>

Your selected adjacency matrix has a cycle in it, which is not appropriate for this situation.]]>*None of these * was wrong.

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

"+""+"

") } ]]>

"+SVG_graph5%QUESTION.NUMBER% + "

"
ET = EquationText%QUESTION.NUMBER%
COR = Correct%QUESTION.NUMBER%
//alert(SVG_plot%QUESTION.NUMBER%)
Nwidth=getFontSize()/16*310
Nheight=getFontSize()/16*80
a1="__SOLUTION__

This question is asking to find a spanning tree for the given adjacency matrix. A __spanning tree__ is a subset of a graph that is connected to all vertices and has no cycles. In upper level mathematics, it can be seen how spanning trees are useful for determining shortest paths between two communities, least expensive methods for organizing a business, and much more.

For the four adjacency matrices from which to choose, **first** look at them to see that they are connecting all vertices *and* that they have no cycles (This ensures it is a spanning tree.). **Second**, take each candidate, even if you only have one, to see that all of the edges correspond to edges in the given adjacency matrix. If even one edge is not correct, then that candidate must be removed. If all of the edges correspond to edges in the given adjacency matrix, then you have the correct solution.

";
if(Correct%QUESTION.NUMBER% == "None of these!"){
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is "+COR+". However, a possible correct solution would look like this.

"+SVG_graph%QUESTION.NUMBER%+"

";
}else{
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is "+COR+"

";
}
for ( var i=5; i

"+Answer%QUESTION.NUMBER%+".

"}
else
{document.forms[0].elements[item+3].value =
"Your answer

"+document.forms[0].elements[item].value+"

was correct.

"}
}
else
{
if (document.forms[0].elements[item].value==Distractor1%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is incorrect. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor2%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is wrong. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor3%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was incorrect. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor4%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was wrong. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="None of these!")
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is not the right answer. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="I don't know!")
{document.forms[0].elements[item+3].value=
" You did not know!

"+ANS+"

"+SHOW+"

" }
}
}
}
}
}
}
}
}
}
document.forms[0].elements[item+3].value = QT + ET + QT1 + SVGG + document.forms[0].elements[item+3].value
}
Choice%QUESTION.NUMBER% = new Array(4)
function question%QUESTION.NUMBER%()
{
labels = new Array();
n = displayarray(1, 6, 9, 0)-0;
pick = Math.round((Math.random()*(n-2))+1);
first = Math.round(Math.random()*(n/3)+1);
last = Math.round(Math.random()*(n/3) + first + 1);
heshe = "";
person = "";
sexflip = Math.round(Math.random());
random = Math.round(Math.random()*100);
if(sexflip == 0){
person += malename(random);
heshe += "he";
}else{
person += femalename(random);
heshe += "she";
}
traveltoss = displayarray(1,0,3,1);
traveltossword = new Array("ferry","bus","train","plane");
A = getrandommatrix(n, n, 0, 0, 1);
mix = displayarray(n,1,n,0);
for(i = 1; i <= n-1; i++){
select = (displayarray(1,1,i,0))-0;
A[mix[select-1]][mix[i]] = (A[mix[select-1]][mix[i]]-0)+1;
}
for(i = 1; i <= n; i++){
labels[i]=alphabet(i-1,1);
for(j = 1; j <= n; j++){
A[i][j] = Math.max(A[i][j]-0,A[j][i]-0);
}
}
B = getrandommatrix(n, n, 0, 0, 1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
B[i][j] = Math.round(Math.random()*Math.sin(Math.PI/4));
}
}
//DISTRACTOR D1: Edge added to give a cycle.
D1 = getrandommatrix(n,n,0,0,1);
mix1 = displayarray(n,1,n,0);
cycle_length = Math.round(Math.random()*(n-4))+3;
for(i = 1; i <= cycle_length-1; i++){
D1[mix1[i-1]][mix1[i]] = (D1[mix1[i-1]][mix1[i]]-0)+1;
}
D1[mix1[0]][mix1[cycle_length-1]] = (D1[mix1[0]][mix1[cycle_length-1]]-0)+1;
for(i = cycle_length-1; i <= n-1; i++){
select1 = (displayarray(1,1,i,0))-0;
D1[mix1[select1-1]][mix1[i]] = (D1[mix1[select1-1]][mix1[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D1[i][j] = Math.max(D1[i][j]-0,D1[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D1[i][i] = (D1[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D1[i][j] > 1){
D1[i][j] = ((D1[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D2: Edge removed from one vertex to destroy spanning tree.
D2 = getrandommatrix(n,n,0,0,1);
mix2 = new Array();
cointoss = Math.round(Math.random());
if(cointoss == 0){
for(i = 0; i <= n-1; i++){
mix2[i] = mix[i];
}
}else{
for(i = 0; i <= n-1; i++){
mix2[i] = mix1[i];
}
}
//First half of list is scrambled to create semi-new list.
changing_point = Math.round(n/2);
sublist = new Array();
for(i = 0; i <= changing_point - 1; i++){
sublist[i] = mix2[i]-0;
}
confusion = displayarray(changing_point,0,changing_point-1,1);
for(i = 0; i <= changing_point - 1; i++){
mix2[i] = sublist[confusion[i]-0];
}
//___
for(i = 1; i <= n-2; i++){
select2 = (displayarray(1,1,i,0))-0;
D2[mix2[select2-1]][mix2[i]] = (D2[mix2[select2-1]][mix2[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D2[i][j] = Math.max(D2[i][j]-0,D2[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D2[i][i] = (D2[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D2[i][j] > 1){
D2[i][j] = ((D2[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D3: 1 edge in spanning tree is not in graph
D3 = getrandommatrix(n,n,0,0,1);
pick_a_list = Math.round(Math.random()*2);
mix3 = new Array();
if(pick_a_list == 0){
for(i = 0; i <= n-1; i++){
mix3[i] = mix[i];
}
}else if(pick_a_list == 1){
for(i = 0; i <= n-1; i++){
mix3[i] = mix1[i];
}
}else if(pick_a_list == 2){
for(i = 0; i <= n-1; i++){
mix3[i] = mix2[i];
}
}
for(i = 1; i <= n-1; i++){
select3 = (displayarray(1,1,i,0))-0;
D3[mix3[select3-1]][mix3[i]] = (D3[mix3[select3-1]][mix3[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D3[i][j] = Math.max(D3[i][j]-0,D3[j][i]-0);
}
}
//Finished below Correct Matrix C.
//DISTRACTOR D4: Spanning tree cut into 2 smaller trees, thus no longer spanning the graph.
D4 = getrandommatrix(n,n,0,0,1);
pick_a_new_list = Math.round(Math.random()*2);
mix4 = new Array();
if(pick_a_new_list == 0){
for(i = 0; i <= n-1; i++){
mix4[i] = mix[i];
}
}else if(pick_a_new_list == 1){
for(i = 0; i <= n-1; i++){
mix4[i] = mix1[i];
}
}else if(pick_a_new_list == 2){
for(i = 0; i <= n-1; i++){
mix4[i] = mix2[i];
}
}
cut = Math.round(n/2);
for(i = 1; i <= cut-2; i++){
select4 = (displayarray(1,1,i,0))-0;
D4[mix4[select4-1]][mix4[i]] = (D4[mix4[select4-1]][mix4[i]]-0)+1;
}
for(i = cut; i <= n-1; i++){
select5 = (displayarray(1,cut,i,0))-0;
D4[mix4[select5-1]][mix4[i]] = (D4[mix4[select5-1]][mix4[i]]-0)+1;
}
calculate = new Array();
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
if(D4[i][j] > 0){
calculate[i] += 1;
}
}
if(calculate[i] == 0){
new_j = displayarray(2,1,n,0);
if(new_j[0] == i){
D4[i][new_j[1]] = ((D4[i][new_j[1]]-0)*0)+1;
}else{
D4[i][new_j[0]] = ((D4[i][new_j[0]]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
D4[i][i] = (D4[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D4[i][j] > 1){
D4[i][j] = ((D4[i][j]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D4[i][j] = Math.max(D4[i][j]-0,D4[j][i]-0);
}
}
//Combined matrix C.
C = getrandommatrix(n,n,0,0,1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
C[i][j] = (A[i][j]-0)+(D1[i][j]-0)+(D2[i][j]-0)+(D3[i][j]-0)+(D4[i][j]-0);
if(C[i][j] > 1){
C[i][j] = (C[i][j]*0)+1;
}
}
C[i][i] = (C[i][i]*0);
}
//Remainder of D3.
switch_to_x = 0;
switch_to_y = 0;
switch_from_x = 0;
switch_from_y = 0;
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
for(k = 1; k <= n; k++){
if(C[i][j] == 0 && D3[i][j] == 0 && i !== j && D3[i][k] == 1){
switch_to_x = (switch_to_x*0)+i;
switch_to_y = (switch_to_y*0)+j;
switch_from_x = (switch_from_x*0)+i;
switch_from_y = (switch_from_y*0)+k;
}
}
}
}
D3[switch_from_x][switch_from_y] = (D3[switch_from_x][switch_from_y]-0)*0;
D3[switch_to_x][switch_to_y] = ((D3[switch_to_x][switch_to_y]-0)*0)+1;
D3[switch_from_y][switch_from_x] = (D3[switch_from_y][switch_from_x]-0)*0;
D3[switch_to_y][switch_to_x] = ((D3[switch_to_y][switch_to_x]-0)*0)+1;
for(i = 1; i <= n; i++){
D3[i][i] = (D3[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D3[i][j] > 1){
D3[i][j] = ((D3[i][j]-0)*0)+1;
}
}
}
//___
toss = Math.round(Math.random());
toss = 0;
// if toss = 0, then the matrices below are symmetric
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];
D1[i][j] = D1[j][i];
D4[i][j] = D4[j][i];
D2[i][j] = D2[j][i];
D3[i][j] = D3[j][i];
}
}
}
tell_me_a_story = Math.round(Math.random()*3);
if(tell_me_a_story == 0){
QuestionText%QUESTION.NUMBER% = "

A large corporate business is divided into "+n+" departments. However, in order to be successful, proper management and cooperation of the departments is required. The adjacency matrix below shows all of the connections between departments, "+alphabet(0,1)+" to "+alphabet(n-1,1)+".

";
QuestionText1%QUESTION.NUMBER% = "

In business, cooperation is important and thus, departments will rely on each other for adequate service and help when needed. The C.E.O. of the company wants to show this to all employees at an upcoming business meeting by removing connections between companies that are either unnecessary or that create cycles between a subset of the departments, which could allow for disorganization within the company. Doing this could possibly save the company millions.

Which of the adjacency matrices below best represents such a graph?

";
}else if(tell_me_a_story == 1){
QuestionText%QUESTION.NUMBER% = "

"
QuestionText1%QUESTION.NUMBER% = "

Which of the adjacency matrices below is a spanning tree for the adjacency matrix above?

";
}else if(tell_me_a_story == 2){
QuestionText%QUESTION.NUMBER% = "

In a study at "+randomname(university)+", "+n+" university student services are being compared and similarities between pairs of services are noted by creating edges and displaying them in the following adjacency matrix.

";
QuestionText1%QUESTION.NUMBER% = "

The organizer of this activity wants to show that all services can be connected by a spanning tree. Which, if any, of the following adjacency matrices represents this?

";
}else if(tell_me_a_story == 3){
QuestionText%QUESTION.NUMBER% = "

"+n+" towns located in "+randomname(commonwealth)+" are connected through major roads, represented as edges in the adjacency matrix below.

";
QuestionText1%QUESTION.NUMBER% = "

Which adjacency matrix below illustrates a possible tree (i.e. no cycles) between all "+n+" towns?

";
}
Nwidth1 = getFontSize()/16*(n * 45) ;
//Nwidth2 = getFontSize()/16*(n * 35) ;
Nheight = getFontSize()/16*(n * 50) ;
m1="

"; SVG_graph1%QUESTION.NUMBER% = SVG_digraph(D1,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph2%QUESTION.NUMBER% = SVG_digraph(D2,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph3%QUESTION.NUMBER% = SVG_digraph(D3,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph4%QUESTION.NUMBER% = SVG_digraph(D4,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph5%QUESTION.NUMBER% = SVG_digraph(C,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start); Correct%QUESTION.NUMBER% = m1+m2+m3+c1+"

"; EquationText%QUESTION.NUMBER% = m1+m2+m3+c2; 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[0] = Distractor1%QUESTION.NUMBER% WhichDistractor[1] = Distractor2%QUESTION.NUMBER% WhichDistractor[2] = Distractor3%QUESTION.NUMBER% WhichDistractor[3] = 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[3]]; } else { Choice%QUESTION.NUMBER%[xxx] = Correct%QUESTION.NUMBER% } Choice%QUESTION.NUMBER%[xxx+randomisation[0]] = WhichDistractor[randomisation2[0]]; Choice%QUESTION.NUMBER%[xxx+randomisation[1]] = WhichDistractor[randomisation2[1]]; Choice%QUESTION.NUMBER%[xxx+randomisation[2]] = WhichDistractor[randomisation2[2]]; 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%[5] = Correct%QUESTION.NUMBER% Choice%QUESTION.NUMBER%[6] = "I don't know!" } else { Choice%QUESTION.NUMBER%[5] = "None of these!" Choice%QUESTION.NUMBER%[6] = "I don't know!" } radio = "" for ( i=1; i<7; i++ ) { if ( i==1 ) {document.write(QuestionText%QUESTION.NUMBER% + EquationText%QUESTION.NUMBER%+QuestionText1%QUESTION.NUMBER%+"

" + radio + Choice%QUESTION.NUMBER%[i] + "

")}
else
{document.write(radio + Choice%QUESTION.NUMBER%[i] + "

")}
}
document.write('')
document.write('')
}
if ( document.forms[0].name == "FEEDBACK" )
{}
else
{question%QUESTION.NUMBER%()}
]]>

Your selected adjacency matrix has a cycle in it, which is not appropriate for this situation.]]>*None of these * was wrong.

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

"+""+"

") } ]]>

"
ET = EquationText%QUESTION.NUMBER%
COR = Correct%QUESTION.NUMBER%
//alert(SVG_plot%QUESTION.NUMBER%)
Nwidth=getFontSize()/16*310
Nheight=getFontSize()/16*80
a1="__SOLUTION__

This question is asking to find a spanning tree for the given graph. A __spanning tree__ is a subset of a graph that is connected to all vertices and has no cycles.

For the four graphs from which to choose, **first** look at them to see that they are connecting all vertices *and* that they have no cycles. (This ensures it is a spanning tree.) **Second**, take each candidate, even if you only have one, to see that all of the edges correspond to edges in the given graph. If even one edge is not correct, then that candidate must be removed. If all of the edges correspond to edges in the given graph, then you have the correct solution.

";
if(Correct%QUESTION.NUMBER% == "None of these!"){
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is "+COR+". However, a possible correct solution would look like this.

"+SVG_graph%QUESTION.NUMBER%+"

";
}else{
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is "+COR+"

";
}
for ( var i=5; i

"+Answer%QUESTION.NUMBER%+".

"}
else
{document.forms[0].elements[item+3].value =
"Your answer

"+document.forms[0].elements[item].value+"

was correct.

"}
}
else
{
if (document.forms[0].elements[item].value==Distractor1%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is incorrect. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor2%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is wrong. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor3%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was incorrect. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor4%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was wrong. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="None of these!")
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is not the right answer. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="I don't know!")
{document.forms[0].elements[item+3].value=
" You did not know!

"+ANS+"

"+SHOW+"

" }
}
}
}
}
}
}
}
}
}
document.forms[0].elements[item+3].value = QT + ET + QT1 + SVGG + document.forms[0].elements[item+3].value
}
Choice%QUESTION.NUMBER% = new Array(4)
function question%QUESTION.NUMBER%()
{
labels = new Array();
n = displayarray(1, 6, 9, 0)-0;
pick = Math.round((Math.random()*(n-2))+1);
first = Math.round(Math.random()*(n/3)+1);
last = Math.round(Math.random()*(n/3) + first + 1);
heshe = "";
person = "";
sexflip = Math.round(Math.random());
random = Math.round(Math.random()*100);
if(sexflip == 0){
person += malename(random);
heshe += "he";
}else{
person += femalename(random);
heshe += "she";
}
traveltoss = displayarray(1,0,3,1);
traveltossword = new Array("ferry","bus","train","plane");
A = getrandommatrix(n, n, 0, 0, 1);
mix = displayarray(n,1,n,0);
for(i = 1; i <= n-1; i++){
select = (displayarray(1,1,i,0))-0;
A[mix[select-1]][mix[i]] = (A[mix[select-1]][mix[i]]-0)+1;
}
for(i = 1; i <= n; i++){
labels[i]=alphabet(i-1,1);
for(j = 1; j <= n; j++){
A[i][j] = Math.max(A[i][j]-0,A[j][i]-0);
}
}
B = getrandommatrix(n, n, 0, 0, 1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
B[i][j] = Math.round(Math.random()*Math.sin(Math.PI/4));
}
}
//DISTRACTOR D1: Edge added to give a cycle.
D1 = getrandommatrix(n,n,0,0,1);
mix1 = displayarray(n,1,n,0);
cycle_length = Math.round(Math.random()*(n-4))+3;
for(i = 1; i <= cycle_length-1; i++){
D1[mix1[i-1]][mix1[i]] = (D1[mix1[i-1]][mix1[i]]-0)+1;
}
D1[mix1[0]][mix1[cycle_length-1]] = (D1[mix1[0]][mix1[cycle_length-1]]-0)+1;
for(i = cycle_length-1; i <= n-1; i++){
select1 = (displayarray(1,1,i,0))-0;
D1[mix1[select1-1]][mix1[i]] = (D1[mix1[select1-1]][mix1[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D1[i][j] = Math.max(D1[i][j]-0,D1[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D1[i][i] = (D1[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D1[i][j] > 1){
D1[i][j] = ((D1[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D2: Edge removed from one vertex to destroy spanning tree.
D2 = getrandommatrix(n,n,0,0,1);
mix2 = new Array();
cointoss = Math.round(Math.random());
if(cointoss == 0){
for(i = 0; i <= n-1; i++){
mix2[i] = mix[i];
}
}else{
for(i = 0; i <= n-1; i++){
mix2[i] = mix1[i];
}
}
//First half of list is scrambled to create semi-new list.
changing_point = Math.round(n/2);
sublist = new Array();
for(i = 0; i <= changing_point - 1; i++){
sublist[i] = mix2[i]-0;
}
confusion = displayarray(changing_point,0,changing_point-1,1);
for(i = 0; i <= changing_point - 1; i++){
mix2[i] = sublist[confusion[i]-0];
}
//___
for(i = 1; i <= n-2; i++){
select2 = (displayarray(1,1,i,0))-0;
D2[mix2[select2-1]][mix2[i]] = (D2[mix2[select2-1]][mix2[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D2[i][j] = Math.max(D2[i][j]-0,D2[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D2[i][i] = (D2[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D2[i][j] > 1){
D2[i][j] = ((D2[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D3: 1 edge in spanning tree is not in graph
D3 = getrandommatrix(n,n,0,0,1);
pick_a_list = Math.round(Math.random()*2);
mix3 = new Array();
if(pick_a_list == 0){
for(i = 0; i <= n-1; i++){
mix3[i] = mix[i];
}
}else if(pick_a_list == 1){
for(i = 0; i <= n-1; i++){
mix3[i] = mix1[i];
}
}else if(pick_a_list == 2){
for(i = 0; i <= n-1; i++){
mix3[i] = mix2[i];
}
}
for(i = 1; i <= n-1; i++){
select3 = (displayarray(1,1,i,0))-0;
D3[mix3[select3-1]][mix3[i]] = (D3[mix3[select3-1]][mix3[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D3[i][j] = Math.max(D3[i][j]-0,D3[j][i]-0);
}
}
//Finished below Correct Matrix C.
//DISTRACTOR D4: Spanning tree cut into 2 smaller trees, thus no longer spanning the graph.
D4 = getrandommatrix(n,n,0,0,1);
pick_a_new_list = Math.round(Math.random()*2);
mix4 = new Array();
if(pick_a_new_list == 0){
for(i = 0; i <= n-1; i++){
mix4[i] = mix[i];
}
}else if(pick_a_new_list == 1){
for(i = 0; i <= n-1; i++){
mix4[i] = mix1[i];
}
}else if(pick_a_new_list == 2){
for(i = 0; i <= n-1; i++){
mix4[i] = mix2[i];
}
}
cut = Math.round(n/2);
for(i = 1; i <= cut-2; i++){
select4 = (displayarray(1,1,i,0))-0;
D4[mix4[select4-1]][mix4[i]] = (D4[mix4[select4-1]][mix4[i]]-0)+1;
}
for(i = cut; i <= n-1; i++){
select5 = (displayarray(1,cut,i,0))-0;
D4[mix4[select5-1]][mix4[i]] = (D4[mix4[select5-1]][mix4[i]]-0)+1;
}
calculate = new Array();
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
if(D4[i][j] > 0){
calculate[i] += 1;
}
}
if(calculate[i] == 0){
new_j = displayarray(2,1,n,0);
if(new_j[0] == i){
D4[i][new_j[1]] = ((D4[i][new_j[1]]-0)*0)+1;
}else{
D4[i][new_j[0]] = ((D4[i][new_j[0]]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
D4[i][i] = (D4[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D4[i][j] > 1){
D4[i][j] = ((D4[i][j]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D4[i][j] = Math.max(D4[i][j]-0,D4[j][i]-0);
}
}
//Combined matrix C.
C = getrandommatrix(n,n,0,0,1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
C[i][j] = (A[i][j]-0)+(D1[i][j]-0)+(D2[i][j]-0)+(D3[i][j]-0)+(D4[i][j]-0);
if(C[i][j] > 1){
C[i][j] = (C[i][j]*0)+1;
}
}
C[i][i] = (C[i][i]*0);
}
//Remainder of D3.
switch_to_x = 0;
switch_to_y = 0;
switch_from_x = 0;
switch_from_y = 0;
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
for(k = 1; k <= n; k++){
if(C[i][j] == 0 && D3[i][j] == 0 && i !== j && D3[i][k] == 1){
switch_to_x = (switch_to_x*0)+i;
switch_to_y = (switch_to_y*0)+j;
switch_from_x = (switch_from_x*0)+i;
switch_from_y = (switch_from_y*0)+k;
}
}
}
}
D3[switch_from_x][switch_from_y] = (D3[switch_from_x][switch_from_y]-0)*0;
D3[switch_to_x][switch_to_y] = ((D3[switch_to_x][switch_to_y]-0)*0)+1;
D3[switch_from_y][switch_from_x] = (D3[switch_from_y][switch_from_x]-0)*0;
D3[switch_to_y][switch_to_x] = ((D3[switch_to_y][switch_to_x]-0)*0)+1;
for(i = 1; i <= n; i++){
D3[i][i] = (D3[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D3[i][j] > 1){
D3[i][j] = ((D3[i][j]-0)*0)+1;
}
}
}
//___
toss = Math.round(Math.random());
toss = 0;
// if toss = 0, then the matrices below are symmetric
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];
D1[i][j] = D1[j][i];
D4[i][j] = D4[j][i];
D2[i][j] = D2[j][i];
D3[i][j] = D3[j][i];
}
}
}
tell_me_a_story = Math.round(Math.random()*3);
if(tell_me_a_story == 0){
QuestionText%QUESTION.NUMBER% = "

A large corporate business is divided into "+n+" departments. However, in order to be successful, proper management and cooperation of the departments is required. The adjacency matrix below shows all of the connections between departments, "+alphabet(0,1)+" to "+alphabet(n-1,1)+".

";
QuestionText1%QUESTION.NUMBER% = "

In business, cooperation is important and thus, departments will rely on each other for adequate service and help when needed. The C.E.O. of the company wants to show this to all employees at an upcoming business meeting by removing connections between companies that are either unnecessary or that create cycles between a subset of the departments, which could allow for disorganization within the company. Doing this could possibly save the company millions.

Which of the graphs below best represents such an adjacency matrix?

";
}else if(tell_me_a_story == 1){
QuestionText%QUESTION.NUMBER% = "

"
QuestionText1%QUESTION.NUMBER% = "

Which of the graphs below is a spanning tree for the adjacency matrix above?

";
}else if(tell_me_a_story == 2){
QuestionText%QUESTION.NUMBER% = "

In a study at "+randomname(university)+", "+n+" university student services are being compared and similarities between pairs of services are noted by creating edges and displaying them in the following adjacency matrix.

";
QuestionText1%QUESTION.NUMBER% = "

The organizer of this activity wants to show that all services can be connected by a spanning tree. Which, if any, of the following graphs represents this?

";
}else if(tell_me_a_story == 3){
QuestionText%QUESTION.NUMBER% = "

"+n+" towns located in "+randomname(commonwealth)+" are connected through major roads, represented as edges in the adjacency matrix below.

";
QuestionText1%QUESTION.NUMBER% = "

Which graphs below illustrates a possible tree (i.e. no cycles) between all "+n+" towns?

";
}
Nwidth1 = getFontSize()/16*(n * 45) ;
//Nwidth2 = getFontSize()/16*(n * 35) ;
Nheight = getFontSize()/16*(n * 50) ;
m1="

"; SVG_graph1%QUESTION.NUMBER% = SVG_digraph(D1,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph2%QUESTION.NUMBER% = SVG_digraph(D2,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph3%QUESTION.NUMBER% = SVG_digraph(D3,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph4%QUESTION.NUMBER% = SVG_digraph(D4,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start)+ "

"; SVG_graph5%QUESTION.NUMBER% = SVG_digraph(C,ratio_along_line,filled,double_path_colour,double_path_skinnyness,svg_start); Correct%QUESTION.NUMBER% = SVG_graph%QUESTION.NUMBER%; EquationText%QUESTION.NUMBER% = m1+m2+m3+c2; Distractor1%QUESTION.NUMBER% = SVG_graph1%QUESTION.NUMBER%; Distractor2%QUESTION.NUMBER% = SVG_graph2%QUESTION.NUMBER%; Distractor3%QUESTION.NUMBER% = SVG_graph3%QUESTION.NUMBER%; Distractor4%QUESTION.NUMBER% = SVG_graph4%QUESTION.NUMBER%; randomisation = displayarray(3,1,3,0); randomisation2 = displayarray(4,0,3,1); WhichDistractor = new Array(4); WhichDistractor[0] = Distractor1%QUESTION.NUMBER% WhichDistractor[1] = Distractor2%QUESTION.NUMBER% WhichDistractor[2] = Distractor3%QUESTION.NUMBER% WhichDistractor[3] = 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[3]]; } else { Choice%QUESTION.NUMBER%[xxx] = Correct%QUESTION.NUMBER% } Choice%QUESTION.NUMBER%[xxx+randomisation[0]] = WhichDistractor[randomisation2[0]]; Choice%QUESTION.NUMBER%[xxx+randomisation[1]] = WhichDistractor[randomisation2[1]]; Choice%QUESTION.NUMBER%[xxx+randomisation[2]] = WhichDistractor[randomisation2[2]]; 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%[5] = Correct%QUESTION.NUMBER% Choice%QUESTION.NUMBER%[6] = "I don't know!" } else { Choice%QUESTION.NUMBER%[5] = "None of these!" Choice%QUESTION.NUMBER%[6] = "I don't know!" } radio = "" for ( i=1; i<7; i++ ) { if ( i==1 ) {document.write(QuestionText%QUESTION.NUMBER% + EquationText%QUESTION.NUMBER%+QuestionText1%QUESTION.NUMBER%+"

" + radio + Choice%QUESTION.NUMBER%[i] + "

")}
else
{document.write(radio + Choice%QUESTION.NUMBER%[i] + "

")}
}
document.write('')
document.write('')
}
if ( document.forms[0].name == "FEEDBACK" )
{}
else
{question%QUESTION.NUMBER%()}
]]>

Your selected graph has a cycle in it, which is not appropriate for this situation.]]>*None of these * was wrong.

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

"+""+"

") } ]]>

"
ET = EquationText%QUESTION.NUMBER%
COR = Correct%QUESTION.NUMBER%
//alert(SVG_plot%QUESTION.NUMBER%)
Nwidth=getFontSize()/16*310
Nheight=getFontSize()/16*80
a1="__SOLUTION__

This question is asking to find a spanning tree for the given graph. A __spanning tree__ is a subset of a graph that is connected to all vertices and has no cycles. In upper level mathematics, it can be seen how spanning trees are useful for determining shortest paths between two communities, least expensive methods for organizing a business, and much more.

For the four graphs from which to choose, **first** look at them to see that they are connecting all vertices *and* that they have no cycles (This ensures it is a spanning tree.). **Second**, take each candidate, even if you only have one, to see that all of the edges correspond to edges in the given graph. If even one edge is not correct, then that candidate must be removed. If all of the edges correspond to edges in the given graph, then you have the correct solution.

";
if(Correct%QUESTION.NUMBER% == "None of these!"){
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is "+COR+". However, a possible correct solution would look like this.

"+SVG_graph%QUESTION.NUMBER%+"

";
}else{
SHOW="

From looking at these graphs and searching for these properties, you should see that the correct answer is

"+COR+"

";
}
for ( var i=5; i

"+Answer%QUESTION.NUMBER%+".

"}
else
{document.forms[0].elements[item+3].value =
"Your answer

"+document.forms[0].elements[item].value+"

was correct.

"}
}
else
{
if (document.forms[0].elements[item].value==Distractor1%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is incorrect. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor2%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is wrong. "+ANS+".

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor3%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was incorrect. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value==Distractor4%QUESTION.NUMBER%)
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

was wrong. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="None of these!")
{document.forms[0].elements[item+3].value=
" Your answer,

"+document.forms[0].elements[item].value+"

is not the right answer. "+ANS+"

"+SHOW+"

" }
else
{
if (document.forms[0].elements[item].value=="I don't know!")
{document.forms[0].elements[item+3].value=
" You did not know!

"+ANS+"

"+SHOW+"

" }
}
}
}
}
}
}
}
}
}
document.forms[0].elements[item+3].value = QT + QT1 + SVGG + document.forms[0].elements[item+3].value
}
Choice%QUESTION.NUMBER% = new Array(4)
function question%QUESTION.NUMBER%()
{
labels = new Array();
n = displayarray(1, 6, 9, 0)-0;
pick = Math.round((Math.random()*(n-2))+1);
first = Math.round(Math.random()*(n/3)+1);
last = Math.round(Math.random()*(n/3) + first + 1);
heshe = "";
person = "";
sexflip = Math.round(Math.random());
random = Math.round(Math.random()*100);
if(sexflip == 0){
person += malename(random);
heshe += "he";
}else{
person += femalename(random);
heshe += "she";
}
traveltoss = displayarray(1,0,3,1);
traveltossword = new Array("ferry","bus","train","plane");
A = getrandommatrix(n, n, 0, 0, 1);
mix = displayarray(n,1,n,0);
for(i = 1; i <= n-1; i++){
select = (displayarray(1,1,i,0))-0;
A[mix[select-1]][mix[i]] = (A[mix[select-1]][mix[i]]-0)+1;
}
for(i = 1; i <= n; i++){
labels[i]=alphabet(i-1,1);
for(j = 1; j <= n; j++){
A[i][j] = Math.max(A[i][j]-0,A[j][i]-0);
}
}
B = getrandommatrix(n, n, 0, 0, 1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
B[i][j] = Math.round(Math.random()*Math.sin(Math.PI/4));
}
}
//DISTRACTOR D1: Edge added to give a cycle.
D1 = getrandommatrix(n,n,0,0,1);
mix1 = displayarray(n,1,n,0);
cycle_length = Math.round(Math.random()*(n-4))+3;
for(i = 1; i <= cycle_length-1; i++){
D1[mix1[i-1]][mix1[i]] = (D1[mix1[i-1]][mix1[i]]-0)+1;
}
D1[mix1[0]][mix1[cycle_length-1]] = (D1[mix1[0]][mix1[cycle_length-1]]-0)+1;
for(i = cycle_length-1; i <= n-1; i++){
select1 = (displayarray(1,1,i,0))-0;
D1[mix1[select1-1]][mix1[i]] = (D1[mix1[select1-1]][mix1[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D1[i][j] = Math.max(D1[i][j]-0,D1[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D1[i][i] = (D1[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D1[i][j] > 1){
D1[i][j] = ((D1[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D2: Edge removed from one vertex to destroy spanning tree.
D2 = getrandommatrix(n,n,0,0,1);
mix2 = new Array();
cointoss = Math.round(Math.random());
if(cointoss == 0){
for(i = 0; i <= n-1; i++){
mix2[i] = mix[i];
}
}else{
for(i = 0; i <= n-1; i++){
mix2[i] = mix1[i];
}
}
//First half of list is scrambled to create semi-new list.
changing_point = Math.round(n/2);
sublist = new Array();
for(i = 0; i <= changing_point - 1; i++){
sublist[i] = mix2[i]-0;
}
confusion = displayarray(changing_point,0,changing_point-1,1);
for(i = 0; i <= changing_point - 1; i++){
mix2[i] = sublist[confusion[i]-0];
}
//___
for(i = 1; i <= n-2; i++){
select2 = (displayarray(1,1,i,0))-0;
D2[mix2[select2-1]][mix2[i]] = (D2[mix2[select2-1]][mix2[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D2[i][j] = Math.max(D2[i][j]-0,D2[j][i]-0);
}
}
for(i = 1; i <= n; i++){
D2[i][i] = (D2[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D2[i][j] > 1){
D2[i][j] = ((D2[i][j]-0)*0)+1;
}
}
}
//DISTRACTOR D3: 1 edge in spanning tree is not in graph
D3 = getrandommatrix(n,n,0,0,1);
pick_a_list = Math.round(Math.random()*2);
mix3 = new Array();
if(pick_a_list == 0){
for(i = 0; i <= n-1; i++){
mix3[i] = mix[i];
}
}else if(pick_a_list == 1){
for(i = 0; i <= n-1; i++){
mix3[i] = mix1[i];
}
}else if(pick_a_list == 2){
for(i = 0; i <= n-1; i++){
mix3[i] = mix2[i];
}
}
for(i = 1; i <= n-1; i++){
select3 = (displayarray(1,1,i,0))-0;
D3[mix3[select3-1]][mix3[i]] = (D3[mix3[select3-1]][mix3[i]]-0)+1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D3[i][j] = Math.max(D3[i][j]-0,D3[j][i]-0);
}
}
//Finished below Correct Matrix C.
//DISTRACTOR D4: Spanning tree cut into 2 smaller trees, thus no longer spanning the graph.
D4 = getrandommatrix(n,n,0,0,1);
pick_a_new_list = Math.round(Math.random()*2);
mix4 = new Array();
if(pick_a_new_list == 0){
for(i = 0; i <= n-1; i++){
mix4[i] = mix[i];
}
}else if(pick_a_new_list == 1){
for(i = 0; i <= n-1; i++){
mix4[i] = mix1[i];
}
}else if(pick_a_new_list == 2){
for(i = 0; i <= n-1; i++){
mix4[i] = mix2[i];
}
}
cut = Math.round(n/2);
for(i = 1; i <= cut-2; i++){
select4 = (displayarray(1,1,i,0))-0;
D4[mix4[select4-1]][mix4[i]] = (D4[mix4[select4-1]][mix4[i]]-0)+1;
}
for(i = cut; i <= n-1; i++){
select5 = (displayarray(1,cut,i,0))-0;
D4[mix4[select5-1]][mix4[i]] = (D4[mix4[select5-1]][mix4[i]]-0)+1;
}
calculate = new Array();
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
if(D4[i][j] > 0){
calculate[i] += 1;
}
}
if(calculate[i] == 0){
new_j = displayarray(2,1,n,0);
if(new_j[0] == i){
D4[i][new_j[1]] = ((D4[i][new_j[1]]-0)*0)+1;
}else{
D4[i][new_j[0]] = ((D4[i][new_j[0]]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
D4[i][i] = (D4[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D4[i][j] > 1){
D4[i][j] = ((D4[i][j]-0)*0)+1;
}
}
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
D4[i][j] = Math.max(D4[i][j]-0,D4[j][i]-0);
}
}
//Combined matrix C.
C = getrandommatrix(n,n,0,0,1);
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
C[i][j] = (A[i][j]-0)+(D1[i][j]-0)+(D2[i][j]-0)+(D3[i][j]-0)+(D4[i][j]-0);
if(C[i][j] > 1){
C[i][j] = (C[i][j]*0)+1;
}
}
C[i][i] = (C[i][i]*0);
}
//Remainder of D3.
switch_to_x = 0;
switch_to_y = 0;
switch_from_x = 0;
switch_from_y = 0;
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++){
for(k = 1; k <= n; k++){
if(C[i][j] == 0 && D3[i][j] == 0 && i !== j && D3[i][k] == 1){
switch_to_x = (switch_to_x*0)+i;
switch_to_y = (switch_to_y*0)+j;
switch_from_x = (switch_from_x*0)+i;
switch_from_y = (switch_from_y*0)+k;
}
}
}
}
D3[switch_from_x][switch_from_y] = (D3[switch_from_x][switch_from_y]-0)*0;
D3[switch_to_x][switch_to_y] = ((D3[switch_to_x][switch_to_y]-0)*0)+1;
D3[switch_from_y][switch_from_x] = (D3[switch_from_y][switch_from_x]-0)*0;
D3[switch_to_y][switch_to_x] = ((D3[switch_to_y][switch_to_x]-0)*0)+1;
for(i = 1; i <= n; i++){
D3[i][i] = (D3[i][i]-0)*0;
for(j = 1; j <= n; j++){
if(D3[i][j] > 1){
D3[i][j] = ((D3[i][j]-0)*0)+1;
}
}
}
//___
toss = Math.round(Math.random());
toss = 0;
// if toss = 0, then the matrices below are symmetric
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];
D1[i][j] = D1[j][i];
D4[i][j] = D4[j][i];
D2[i][j] = D2[j][i];
D3[i][j] = D3[j][i];
}
}
}
tell_me_a_story = Math.round(Math.random()*3);
if(tell_me_a_story == 0){
QuestionText%QUESTION.NUMBER% = "

A large corporate business is divided into "+n+" departments. However, in order to be successful, proper management and cooperation of the departments is required. The graph below shows all of the connections between departments, "+alphabet(0,1)+" to "+alphabet(n-1,1)+".

";
QuestionText1%QUESTION.NUMBER% = "

In business, cooperation is important and thus, departments will rely on each other for adequate service and help when needed. The C.E.O. of the company wants to show this to all employees at an upcoming business meeting by removing connections between companies that are either unnecessary or that create cycles between a subset of the departments, which could allow for disorganization within the company. Doing this could possibly save the company millions.

Which of the following best represents such a graph?

";
}else if(tell_me_a_story == 1){
QuestionText%QUESTION.NUMBER% = "

"
QuestionText1%QUESTION.NUMBER% = "

Which of the following is a spanning tree for the graph above?

";
}else if(tell_me_a_story == 2){
QuestionText%QUESTION.NUMBER% = "

In a study at "+randomname(university)+", "+n+" university student services are being compared and similarities between pairs of services are noted by creating edges and displaying them in the following graph.

";
QuestionText1%QUESTION.NUMBER% = "

The organizer of this activity wants to show that all services can be connected by a spanning tree. Which, if any, of the following represents this?

";
}else if(tell_me_a_story == 3){
QuestionText%QUESTION.NUMBER% = "

"+n+" towns located in "+randomname(commonwealth)+" are connected through major roads, represented as edges in the graph below.

";
QuestionText1%QUESTION.NUMBER% = "

Which of the following illustrates a possible tree (i.e. no cycles) between all "+n+" towns?

";
}
Nwidth1 = getFontSize()/16*(n * 45) ;
//Nwidth2 = getFontSize()/16*(n * 35) ;
Nheight = getFontSize()/16*(n * 50) ;
m1="

"; EquationText%QUESTION.NUMBER% = SVG_graph5%QUESTION.NUMBER%; Distractor1%QUESTION.NUMBER% = SVG_graph1%QUESTION.NUMBER%+ "

"; Distractor2%QUESTION.NUMBER% = SVG_graph2%QUESTION.NUMBER%+ "

"; Distractor3%QUESTION.NUMBER% = SVG_graph3%QUESTION.NUMBER%+ "

"; Distractor4%QUESTION.NUMBER% = SVG_graph4%QUESTION.NUMBER%+ "

"; randomisation = displayarray(3,1,3,0); randomisation2 = displayarray(4,0,3,1); WhichDistractor = new Array(4); WhichDistractor[0] = Distractor1%QUESTION.NUMBER% WhichDistractor[1] = Distractor2%QUESTION.NUMBER% WhichDistractor[2] = Distractor3%QUESTION.NUMBER% WhichDistractor[3] = 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[3]]; } else { Choice%QUESTION.NUMBER%[xxx] = Correct%QUESTION.NUMBER% } Choice%QUESTION.NUMBER%[xxx+randomisation[0]] = WhichDistractor[randomisation2[0]]; Choice%QUESTION.NUMBER%[xxx+randomisation[1]] = WhichDistractor[randomisation2[1]]; Choice%QUESTION.NUMBER%[xxx+randomisation[2]] = WhichDistractor[randomisation2[2]]; 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%[5] = Correct%QUESTION.NUMBER% Choice%QUESTION.NUMBER%[6] = "I don't know!" } else { Choice%QUESTION.NUMBER%[5] = "None of these!" Choice%QUESTION.NUMBER%[6] = "I don't know!" } radio = "" for ( i=1; i<7; i++ ) { if ( i==1 ) {document.write(QuestionText%QUESTION.NUMBER% + EquationText%QUESTION.NUMBER%+QuestionText1%QUESTION.NUMBER%+"

" + radio + Choice%QUESTION.NUMBER%[i] + "

")}
else
{document.write(radio + Choice%QUESTION.NUMBER%[i] + "

")}
}
document.write('')
document.write('')
}
if ( document.forms[0].name == "FEEDBACK" )
{}
else
{question%QUESTION.NUMBER%()}
]]>

Your selected graph has a cycle in it, which is not appropriate for this situation.]]>*None of these * was wrong.

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

Work through the theory above, retry the question at an appropriate time, and if you are still struggling then seek assisstance from a teacher or tutor.]]>

"+""+"

") } ]]>