Problem with navigation graphics

I have a graph of components and relationships between them. User navigation with root component. He presses the extension button on the component to open a new component that is associated with the current component.

The problem is that the user decides to collapse the node. I have to select a hidden tree and at the same time leave the graph in a consistent state so that there is no extended node with a missing relation to another node graph.

Now in case of cyclic / loop between component, it is difficult for me to select subtree. For simplicity, I choose the order in which they were expanded. Therefore, if the A-extension in B and C compresses A, they hide the nodes and edges created by it. Now consider the following scenario.

[-] means an expanded state and [+] means it is not yet expanded. A expands to reveal B and C. And then B expands to reveal D. C expanded, which creates a connection between C and exits node D, and also creates node E. Now the user decides to collapse B. Since the extension order of D is child by B, he will hide and hide D. This leaves the graph in an inconsistent state, since C has an edge to D, but D no longer exists, if I delete the edge of the CD, it will still be inconsistent. If I compress C. And E again, a circular reference, for example in A, produces the same problem.

    /-----B[-]-----\   
A[-]                D[+]
    \-----C[-]-----/
              \
               E[+]

, , . , , node , .

+3
4

node , , node , .

  • Collapsing B node D .
  • Node D , .
  • B D ( D )
  • node C D , .
+1

, B B.

A A, , D A C, D .

, , , - ( , ). , .

0

, , . subgraphp , node, , , node. .

- , "". , , .

0

, ( ) , .

, , , . 2 :

, , , , :

def Expand(node):
  for c in node.childs:
    c.parents.insert(node)
    Display(node, c)
    if len(c.parents) == 1: Display(c)

def Collapse(node):
  for c in node.childs:
    del node in c.parents
    Hide(node, c)
    if len(c.parents) == 0: Collapse(c)

  Hide(node)

Display Hide - , .

0

Source: https://habr.com/ru/post/1743327/


All Articles