Graph and binart tree traversal

Hi all,

I'm pleased to join this forum, and this is my first post, I got some knowledge in C++ but not that much , my field is originally database, however, I have to go through some programming at this point and to be frank reading books is really not a good idea to a slow reader such as myself, I prefer guidance from other sources which lead me to post here :)

Let's get to the point, I used a BFS to simulate graph-join structure in a C++ code, and had a binary tree that asks the user e.g. to insert a node in the tree among other options, anyhow, I reached a point where I should pass a set of vertices from the graph to the tree, but I'm confused how to do so. So I wanted to ask is such a thing possible? i.e. passing vertices from a graph to a tree automatically (no user involvement is needed)?

If more detail is needed please do not hesitate to ask. I prefer to make a short post for now for simplicity and comprehension.

Best regards
Last edited on
I admit confusion about your question.

The tree is supposed to represent the graph, correct? How is a breadth-first search simulating the joining of graphs? How do you deal with loops? Is your graph directed?

If you have new vertices, just insert each one into your tree.
Yes it is possible. Create a list of the vertices by "iterating" through your graph and. Finally insert each element from the list into the tree by calling your tree's insert method for each element.
Smac89 thank you, I will give it a try :)
I will let you know if I had any issues.

As for Duoas, from what I know trees represent graphs indeed but I need a graph traversal for simulating what is called join-graph structure, and I need the tree to simulate an algorithm by the name of iterative improvement. As for the directed and undiracted, for now it is directed.
So you aren't actually joining the graphs -- just treating two (or more) as if they were for some operation?

Are the nodes so expensive that it wouldn't be simpler just to create a temporary join-graph?


I am still confused about your statement: "I reached a point where I should pass a set of vertices from the graph to the tree, but I'm confused how to do so."

The tree is your graph, and the nodes in the tree are the vertices, and the pointers linking nodes are edges. I presume you understand that, so I am at a loss as to your confusion over passing vertices 'from graph to tree'. What am I missing?

The user involvement thing is a separate issue.

All things the computer does is precipitated by some kind of event. You must identify the condition that would qualify "passing vertices from graph to tree." (Though I still don't see what you mean by that. How is the graph not the tree? Are you talking about user input of some kind? Drawing dots on a window with lines connecting them? Dots obtained from some 'user' -- not your program -- source?)
Topic archived. No new replies allowed.