i have a problem i am very new to c++ and want to construct a minimum spanning tree for 8 stocks i have calculated in excel the relevant formulas and know the weights of each of gthe vertices but don't know how to construct it i have read numerous books and have managed to get a pseudo code for how it should be which is
Algorithm spanningTree (graph)
Determine the minimum spanning tree a network.
Pre graph contains a network
Post spanning tree determined
1 if (empty graph)
1 return
2 end if
3 loop (through all vertices)
Set inTree flags false.
1 set vertex inTree flag to false
2 loop (through all edges)
1 set edge inTree flag to false
2 get next edge
3 end loop
4 get next vertex
4 end loop
Now derive spanning tree
5 set first vertex to in tree
6 set treeComplete to false
7 loop (not treeComplete)
1 set treeComplete to true
2 set minEdge to maximum integer
3 set minEdgeLoc to null
4 loop (through all vertices)
Walk through graph checking vertices in tree.
1 if (vertex in tree AND vertex outDegree > 0)
1 loop (through all edges)
1 if (destination not in tree)
set destination inTree flag to false)
1 set treeComplete to false
2 if (edge weight < minEdge)
1. set minEdge to edge weight
2 set minEdgeLoc to edge
3 end if
2 end if
3 get next edge
2 end loop
2 end if
3 get next vertex
5 end loop
6 if (minEdgeLoc not null)
Found edge to insert into tree.
1. set minEdgeLoc inTree flag to true
2 set destination inTree flag to true
7 end if
8 end loop
end SpanningTree
the structure should be
graphHead
count
first
end graphHead
graphVertex
nextVertex
data
inDegree
outDegree
inTree
firstEdge
end graphVertex
graphEdge
destination
weight
nextEdge
inTree
end graphEdge
if any one can please give me examples in the psedo code or point out what to input and where then that wud be really helpful as i am so distressed xxx