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?

Dani AI

Generated

Short answer: yes — a GUI can represent a graph backend and let taps yield node or edge info. For a residential-block map, keep the graph model (nodes, edges, attributes, IDs, coordinates) completely separate from rendering. The view should only draw and forward transformed touch points to a controller that resolves which model element was intended and opens the info panel.

For reliable selection, convert the touch point from screen to world coordinates once (accounting for pan/zoom). Hit-test nodes first using a radius and z-order (this avoids accidental edge picks when a node sits on a line). If no node is hit, test edges by checking the nearest distance to each edge segment against a small tolerance. For larger graphs, avoid brute-force checks by using a spatial index (quadtree/grid) or precomputed bounding boxes so hit tests stay fast. Visualizing the hit zones while debugging greatly speeds up tuning tolerances.

UX and editing patterns that work well on mobile: tap to show a bottom sheet or panel with details, long-press to enter edit mode, drag to move nodes, drag from a node to create an edge, pinch/zoom and pan for navigation. If the underlying coordinates are real-world, use a map overlay approach (map SDK or tiled base imagery) so features can snap to geo coordinates and stay consistent with zoom levels. Provide clear selection highlights and an undo stack for safe edits.

Persistence and performance: serialize the model (Room/SQLite or JSON), give nodes stable IDs, and keep a change history for undo. Optimize rendering by reusing paint/bitmap objects, invalidating only dirty regions, and throttling expensive layout. Troubleshooting tips: if taps seem off check matrix inversion and screen-density scaling, and if edges are hard to target add invisible hit-strips or an explicit "edge-select" mode. These suggestions build on 's hit-mapping idea and 's GIS hint and should help move from prototype buttons to a robust, touch-friendly graph UI.

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.