Click to See Complete Forum and Search --> : Need help with Graphs


sywaci
April 20th, 2003, 01:53 PM
I have to write some functions to run in a class for a graph...I have to write the class, too. I'm getting confused, though, and I can't seem to find a simple template that'll help me figure out what a graph class even NEEDS. I also think I figured out how to write a constructor, but I'm not sure how the destructor should look...

Oh boy, I'm just lost. :confused:

If anyone could help me out here...if there's some good page that helps with graphs...I'd appreciate it. Everything I've found so far refers to some Vertex class that I don't know anything about...

Thanks,
Rachel AKA sywaci

NigelQ
April 20th, 2003, 02:01 PM
There is a great class for producing graphs here (http://codeguru.earthweb.com/controls/graphBrian.shtml)

I guess the first thing you need to ask yourself is what type of graph you need. This may depend of the type of data you want to represent.

What are you struggling with - the concept of drawing a graph (see link above) or tranlating your data into something that can be represented by a graph?

Hope this helps,

- Nigel

sywaci
April 20th, 2003, 02:08 PM
Well, first of all, I'm doing this in regular C++, not Visual. What I have to do is read # of vertices and # of edges from a text file, and then have a class to do things like add a new edge, check if vertices are connected, and output all the connected components.

I understand these concepts, but I have trouble translating them into concrete code. I can't even figure out the simple stuff like constructors and destructors half the time...

I'll bet an English major would be easy. :rolleyes:

Rachel

galathaea
April 20th, 2003, 05:55 PM
For a nice graph library to read over and see how it works, check out the graph library found at www.boost.org and download the code. I highly suspect it will become standard c++ in the next standardization because it is so nicely written. You have all sorts of operations coded for applying to the graphs, like connectivity and traversals. I really think their library would be a perfect read to get you started on designing your own classes, and it is very pure c++ for use on many platforms.

NigelQ
April 20th, 2003, 06:34 PM
What platform are you targetting and what software / technologies are you using?

If Windows is the target platform, you can use the GDI functionality APIs to draw descrete primative objects such as lines, rectangles and text etc.

If you want something more than a quick and dirty approach, you need to ask yourself whether you should use a bolt-on technology such as Open-GL (cross-platform) or DirectX (Microsoft specific) to help in making things look pretty.

You may even be able to use Excel to perform your output plotting for you. Some significantly complex graphs can be generated using Excel, the output of which can then be displayed by your own application.

Hope this helps,

- Nigel

galathaea
April 20th, 2003, 07:39 PM
NigelQ, I think the question revolves around the combinatorial objects called graphs, which are just vertices and edges, and it seems that he wants them used abstractly as mathematical objects to perform manipulations on. The first post was a little confusing, but I think if I am reading the posts correctly, the OP is not discussing the drawings also known as graphs which display how data is related...