Graph navigation problem
Posted
by affan
on Stack Overflow
See other posts from Stack Overflow
or by affan
Published on 2010-04-29T10:24:43Z
Indexed on
2010/04/29
10:27 UTC
Read the original article
Hit count: 450
I have graph of components and relation between them. User open graph and want to navigate through the graph base on his choice. He start with root node and click expand button which reveal new component that is related to current component.
The problem is with when use decide to collapse a node. I have to choose a sub-tree to hide and at same time leave graph in consistent state so that there is no expanded node with missing relation to another node in graph.
Now in case of cyclic/loop between component i have difficult of choosing sub-tree. For simplicity i choose the order in which they were expanded. So if a A expand into B and C collapse A will hide the nodes and edge that it has created. Now consider flowing scenario. [-] mean expanded state and [+] mean not yet expanded. A is expanded to reveal B and C. And then B is expanded to reveal D. C is expanded which create a link between C and exiting node D and also create node E. Now user decide to collapse B. Since by order of expansion D is child of B it will collapse and hide D. This leave graph in inconsistent state as C is expanded with edge to D but D is not anymore there if i remove CD edge it will still be inconsistent. If i collapse C. And E is again a cyclic link e.g to B will produce the same problem.
/-----B[-]-----\
A[-] D[+]
\-----C[-]-----/
\
E[+]
So guys any idea how can i solve this problem. User need to navigate through graph and should be able to collapse but i am stuck with problem of cyclic nodes in which case any of node in loop if collapse will leave graph in inconsistent state.
© Stack Overflow or respective owner