473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Minimum spanning tree problem??

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
Mar 25 '07 #1
1 2625
sicarie
4,677 Expert Mod 4TB
It looks like you have pseudo code there for something, but I'm not sure I understand your problem. What is in the Excel sheet, and how does that relate to the spanning tree algorithm?
Mar 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: _mario.lat | last post by:
kruskal:minimum spanning tree. how to do? I'd like to find the minimum spanning tree with kruskal algorithm. There is a code (in C++) written? which contenitor do you suggest (Vector, set, ...)?...
7
by: sugaray | last post by:
the binary search tree node here contains another structure as it's data field, programs did successfully work when data field is int, char, this time i got stucked, don't know why ? if there's...
5
by: Mike | last post by:
Why does this code insert a node into a binary search tree correctly? If I only inserting going by first digit it works properly but when I try inserting going by the whole ip and the port number...
2
by: pyguy | last post by:
Hi all, I am running into a conceptual glitch in implementing a simple binary tree class. My insertion and printing (sorting) seems to be ok, but when I search the tree, my find method isn't doing...
2
by: tonokio | last post by:
I wasn't sure if this was the best place to post since there isn't really an algorithm section for programming. I was curious that if you're given a MST tree of G and P is the shortest path between...
2
by: zahit | last post by:
Hi guys, below there is a c code which caluclates given data repetition in a binary tree. typedef struct node *tree_pointer; typedef struct node{ char data; tree pointer left_child,...
3
by: FARAECHILIBRU | last post by:
i'm building a binary tree the problem is when i'm reading from e text file .First i'm sending to tree builder function a empty node and e new node the function return me firt node of a tree, but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.