Is there a way to develop a GUI which has graph data structure at the backend so that if we want to have information about a particular node or edge, we just tap its corresponding GUI representation and the app gives us the required info?

Recommended Answers

All 4 Replies

Yes.
The simplest way is to display each node as some kind of button. Edges are a bit more fiddly - you proably want to allow the user to tap "close" to the line because the line itself will be a difficultly small target. If the graph is tidy, with no overlap of edges then you can use buttons for the edges as well (transparent button with a line drawn across it). Otherwize you will have to draw the edges as lines and have some code to determine if a tap is on or close to an edge line - which would need a little thought, but the code's not too hard.

well i am trying to create a map of my residential block. Is it possible to use graph data structure as backend and buttons as GUI?

Yes, absolutely. Although Buttons are the simplest to implement, you may not get the look and feel that you really want, so a better general solution is:
As you draw the graph in your GUI you store the Shape (maybe just a simple Rectangle) of the thing you just drew for each node or edge etc. With each such shape store the object it represents (ie create a Map with the Shape as key and the node/edge object as the value).
Now when the user interacts with the GUI you can loop through the stored Shapes to see which one the user has tapped (use Shape's contains(tapped Point) method) and use that to get the object it represents. Then you can display all the info for that object.
Frankly, that part of the code is really easy. The hardest part is coming up with code that draws the graph ina way that is clear and looks good.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.