Sign in to follow this  

creating a dynamic 2D graph

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to create a 2d graph consisting of nodes with links (one way arrows) between them (something that looks kinda like a finite state machine). there will be an iniitial set of nodes that the program will get from a file, then i want the user to be able to insert and delete nodes. i think i'm going to implement the graph structure as an adjacency matrix. what i'm trying to decide is what would be the best way to draw the graph and still allow for user input in the same screen (i.e. what, if any, api should i use). i'm familiar w/ directX and a little familiar w/ openGL. any thoughts would be appreciated.

Share this post


Link to post
Share on other sites
Either of those should be fine. You basically need some kind of picking mechanism to determine which node was hit, as well as a layout algorithm to draw everything. So to start, you could lay things out on a square(ie, if you have x nodes, make a sqrt(x) x sqrt(x) grid, with the last column missing some nodes if needed). Then draw the nodes as circles or squares, and the connections as rectangles, with a triangle for the arrow. You could do something like click and drag from a node to a node creates a transition. And right click on a transition deletes it...or something like that.

As for apis, go with what you're familiar with. Any of them should work just fine, as long as you know how to handle input.

Share this post


Link to post
Share on other sites

This topic is 4836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this