"); //// edges that will form a cycle
for (i = 1; i <= n-1; i++){
for (j = i+1; j <= n; j++){
if(A[i][j] == 1){
weights[i][j] = A[i][j]*Math.ceil(Math.random()*9)+19;}
else if(A[i][j] == 0){
weights[i][j] = A[i][j]+999;}
}}
for(i = 0; i ";
stop = (stop-0)+1;}
else if(stop ");
////////
Nwidth1 = getFontSize()/16*(n * 60) ;
Nheight = getFontSize()/16*(n * 60) ;
m1=""
QuestionText1%QUESTION.NUMBER% = "This question asks whether or not the edge "+q_edge[e]+" was considered when Kinga applied Prim's algorithm. If it was considered, at which step was it added/rejected? "+starting+" was Kinga's starting vertex. Important: Since edge "+q_edge[e]+" was accepted at STEP "+e+" your answer should be ";
Feedback2%QUESTION.NUMBER%=" Since edge "+q_edge[e]+" was rejected at STEP "+e+" your answer should be ";
Feedback3%QUESTION.NUMBER%=" Since edge "+q_edge[e]+" was not considered when finding the minimum spanning tree your answer should be ";
conclusion = "";
if (which_conclusion[e]=="first"){conclusion = Feedback1%QUESTION.NUMBER%;}
else if (which_conclusion[e]=="second"){conclusion = Feedback2%QUESTION.NUMBER%;}
else {conclusion = Feedback3%QUESTION.NUMBER%;}
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
"
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
/////////////////
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") +"
"+ eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else {
for(nc=step; nc<=noofedges; nc++){
i_rej = bin.shift();
q_edge[nc]=labels[i_rej[0]]+labels[i_rej[1]];
answ[nc]="NC";
which_conclusion[nc]="third";}
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
correct = answ[e];
Correct%QUESTION.NUMBER% = correct;
//document.write(Correct%QUESTION.NUMBER%+"
";
QuestionText2%QUESTION.NUMBER% = "In case you cannot read the weights on the graph, please use the Network Matrix below.
";
QuestionText3%QUESTION.NUMBER% = "
";
EquationText1%QUESTION.NUMBER%=m1+m2+m3+c1%QUESTION.NUMBER%+"
Input your answer in upper case letters in the box below. Please follow the instructions for the answer format written under the input box.
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
Feedback1%QUESTION.NUMBER%="
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+MST+".
"+conclusion+" "+Correct%QUESTION.NUMBER%+"";
//document.write(Feedback%QUESTION.NUMBER%+"
"); //// edges that will form a cycle
for (i = 1; i <= n-1; i++){
for (j = i+1; j <= n; j++){
if(A[i][j] == 1){
weights[i][j] = A[i][j]*Math.ceil(Math.random()*9)+19;}
else if(A[i][j] == 0){
weights[i][j] = A[i][j]+999;}
}}
for(i = 0; i ";
stop = (stop-0)+1;}
else if(stop ");
////////
Nwidth1 = getFontSize()/16*(n * 60) ;
Nheight = getFontSize()/16*(n * 60) ;
m1=""
QuestionText1%QUESTION.NUMBER% = "This question asks whether or not the edge "+q_edge[e]+" was considered when Kinga applied Prim's algorithm. If it was considered, at which step was it added/rejected? "+starting+" was Kinga's starting vertex. Important: Since edge "+q_edge[e]+" was accepted at STEP "+e+" your answer should be ";
Feedback2%QUESTION.NUMBER%=" Since edge "+q_edge[e]+" was rejected at STEP "+e+" your answer should be ";
Feedback3%QUESTION.NUMBER%=" Since edge "+q_edge[e]+" was not considered when finding the minimum spanning tree your answer should be ";
conclusion = "";
if (which_conclusion[e]=="first"){conclusion = Feedback1%QUESTION.NUMBER%;}
else if (which_conclusion[e]=="second"){conclusion = Feedback2%QUESTION.NUMBER%;}
else {conclusion = Feedback3%QUESTION.NUMBER%;}
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
"
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
/////////////////
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") +"
"+ eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else {
for(nc=step; nc<=noofedges; nc++){
i_rej = bin.shift();
q_edge[nc]=labels[i_rej[0]]+labels[i_rej[1]];
answ[nc]="NC";
which_conclusion[nc]="third";}
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
correct = answ[e];
Correct%QUESTION.NUMBER% = correct;
//document.write(Correct%QUESTION.NUMBER%+"
";
QuestionText2%QUESTION.NUMBER% = "In case you cannot read the weights on the graph, please use the Network Matrix below.
";
QuestionText3%QUESTION.NUMBER% = "
";
EquationText1%QUESTION.NUMBER%=m1+m2+m3+c1%QUESTION.NUMBER%+"
Input your answer in upper case letters in the box below. Please follow the instructions for the answer format written under the input box.
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
Feedback1%QUESTION.NUMBER%="
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+MST+".
"+conclusion+" "+Correct%QUESTION.NUMBER%+"";
//document.write(Feedback%QUESTION.NUMBER%+"
Important:
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
arrow_ratio_along_line = 0; // places arrow on line: if 0 then no arrow is drawn.
filled = 1; // = 1 filled arrow else open
weights_ratio_along_line = 0.3 // places weights on line: if 0 then no weight is drawn (possibly).
weights_font_colour = "black";
weights_font_scale = 1.3;
SVG_graph%QUESTION.NUMBER% = SVG_network(A,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + " ";
stop = (stop-0)+1;}
else if(stop ");
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
"
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") + "
"+eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else{
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
//document.write(feedback);
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
Correct%QUESTION.NUMBER% = MST;
//document.write(Correct%QUESTION.NUMBER%+"
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+Correct%QUESTION.NUMBER%+".
";
//document.write(Feedback%QUESTION.NUMBER%+"
Important:
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
arrow_ratio_along_line = 0; // places arrow on line: if 0 then no arrow is drawn.
filled = 1; // = 1 filled arrow else open
weights_ratio_along_line = 0.3 // places weights on line: if 0 then no weight is drawn (possibly).
weights_font_colour = "black";
weights_font_scale = 1.3;
SVG_graph%QUESTION.NUMBER% = SVG_network(A,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + " ";
stop = (stop-0)+1;}
else if(stop ");
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
"
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") + "
"+eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else{
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
//document.write(feedback);
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
Correct%QUESTION.NUMBER% = MST;
//document.write(Correct%QUESTION.NUMBER%+"
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+Correct%QUESTION.NUMBER%+".
";
//document.write(Feedback%QUESTION.NUMBER%+"
"); //// edges that will form a cycle
for (i = 1; i <= n-1; i++){
for (j = i+1; j <= n; j++){
if(A[i][j] == 1){
weights[i][j] = A[i][j]*Math.ceil(Math.random()*9)+19;}
else if(A[i][j] == 0){
weights[i][j] = A[i][j]+999;}
}}
for(i = 0; i Important: ";
stop = (stop-0)+1;}
else if(stop ");
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
";
QuestionText2%QUESTION.NUMBER% = "In case you cannot read the weights on the graph, please use the Network Matrix below.
";
QuestionText3%QUESTION.NUMBER% = "
";
EquationText1%QUESTION.NUMBER%=m1+m2+m3+c1%QUESTION.NUMBER%+"
Input two upper case letters in the box below.
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
arrow_ratio_along_line = 0; // places arrow on line: if 0 then no arrow is drawn.
filled = 1; // = 1 filled arrow else open
weights_ratio_along_line = 0.3 // places weights on line: if 0 then no weight is drawn (possibly).
weights_font_colour = "black";
weights_font_scale = 1.3;
SVG_graph%QUESTION.NUMBER% = SVG_network(A,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") +"
"+ eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else{
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
//document.write(feedback);
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
Correct%QUESTION.NUMBER% = correct;
//document.write(Correct%QUESTION.NUMBER%+"
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+MST+".
Then, counting "+e+ordStringOf(e)+" edge gives you the correct answer "+Correct%QUESTION.NUMBER%+"";
//document.write(Feedback%QUESTION.NUMBER%+"
"); //// edges that will form a cycle
for (i = 1; i <= n-1; i++){
for (j = i+1; j <= n; j++){
if(A[i][j] == 1){
weights[i][j] = A[i][j]*Math.ceil(Math.random()*9)+19;}
else if(A[i][j] == 0){
weights[i][j] = A[i][j]+999;}
}}
for(i = 0; i Important: ";
stop = (stop-0)+1;}
else if(stop ");
Feedback%QUESTION.NUMBER%=" For a connected and undirected network, a minimum spanning tree is a connected subgraph of minimum total weight incorporating every vertex of the network. Prim's algorithm: start with defining your starting vertex. Then, connect to it the 'nearest' vertex, that is, the one joined to the starting vertex by the edge with a minimum weight. Afterwards, in each iteration, you connect to the tree of connected vertices that vertex which is 'neareset' to the connected set until all vertices are connected. In the given problem, "+starting+" was a starting vertex. When finding the minimum spanning tree you should have been connecting edges in the following order: ");
document.write(QuestionText1%QUESTION.NUMBER%+SVG_graph%QUESTION.NUMBER%+QuestionText2%QUESTION.NUMBER%+EquationText1%QUESTION.NUMBER%);
document.write("")
document.write(QuestionText3%QUESTION.NUMBER%);
document.write("")
}
if (document.forms[0].name=="FEEDBACK")
{}
else
{question%QUESTION.NUMBER%()}
]]>
";
QuestionText2%QUESTION.NUMBER% = "In case you cannot read the weights on the graph, please use the Network Matrix below.
";
QuestionText3%QUESTION.NUMBER% = "
";
EquationText1%QUESTION.NUMBER%=m1+m2+m3+c1%QUESTION.NUMBER%+"
Input two upper case letters in the box below.
";
//EquationText1%QUESTION.NUMBER% = ""; //just graph displayed
arrow_ratio_along_line = 0; // places arrow on line: if 0 then no arrow is drawn.
filled = 1; // = 1 filled arrow else open
weights_ratio_along_line = 0.3 // places weights on line: if 0 then no weight is drawn (possibly).
weights_font_colour = "black";
weights_font_scale = 1.3;
SVG_graph%QUESTION.NUMBER% = SVG_network(A,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
var stage_number = new Array(n-1);
for (ib=0; ib
"+ i_st+ordStringOf(i_st) +" edge added i.e. " + eval("A"+(i_st)+" = edge"+i_st+"") +"
"+ eval("B"+(i_st)+" = SVG_network(S"+i_st+",weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale)") + "
" + "
"+"The next edge of least weight connected to the tree is "+labels[i_rej[0]]+labels[i_rej[1]]+" however it would form a cycle and therefore is rejected. " + "
";}
else{
feedback += "STOPPING CONDITION
Since all the vertices are now connected the minimum spanning tree has already been formed. Hence, the algorithm stops here." + "
"
i_feed=noofedges;}
}
//document.write(feedback);
SVG_tree_graph%QUESTION.NUMBER% = SVG_network(T,weights,arrow_ratio_along_line,filled,weights_ratio_along_line,weights_font_colour,weights_font_scale) + "
"
Correct%QUESTION.NUMBER% = correct;
//document.write(Correct%QUESTION.NUMBER%+"
"+feedback+" Connecting edges in the indicated order should form a Minimum Spanning Tree: "+MST+".
Then, counting "+e+ordStringOf(e)+" edge gives you the correct answer "+Correct%QUESTION.NUMBER%+"";
//document.write(Feedback%QUESTION.NUMBER%+"