Is there any data structure or database that can handle path expression expressions and path expression queries?

I need to simulate a graph (or it can be thought of as a recursive tree (s), since it is usually one or more roots) based on things having children:

a hasChildren (b, c)
b hasChildren (d, e)
c hasChildren (f, g)
d hasChildren (h, a)

Now there are implicit paths, a / c / f and recursive: a / b / d / a / b / d / ...

And then I need to set things on the graph through the expression of the path, both properties about them (these paths have a color: blue or such), as well as changing their children - perhaps deleting / hiding them or adding new children.

By the expression of the path, I mean something like this:

a/b/** -> color = "blue"

, , a/b/, color = "blue". , a/b/d/a/b/d/a, . a, .

:

**/d/h
a/b/[color="blue"]
a/**/h

, . . , :

a/b/d

, :

a/**[color="blue"]  -- descendants that have attribute color = "blue". This could be infinite in recursive case so we can put a restriction on this type of query to have it make sense, like does such a path exist, or just return first one or something.

, .

a hasChildren (b, c, x, y, z)

, . , , , .

, , , :) 1000 , 1000 100 000 .

-, ?

RDF/OWL, , , .

+5
6
+1

Trie ( Java) Node, Node , ( , .

, . , !

+1

, , , CONNECT BY START WITH .

, NODES :

  • PARENT_ID,
  • ... ,

SELECT ID, PARENT_ID, COLOR FROM NODES START WITH PARENT_ID NULL CONNECT BY PRIOR ID = PARENT_ID

, , WHERE COLOR = 'BLUE' a/b/d/a/b/d

http://www.adp-gmbh.ch/ora/sql/connect_by.html

+1

, , , . sql table. 1) adjaceny, ,

Parent Child
Null   A
A      B
A      C
B      D
B      E

2) , , . SQL Joe Celko, http://en.wikipedia.org/wiki/Nested_set_model

+1

- , , , , # ( - - ). , node, , , .. ( "" ). , , , .

I find it difficult to determine when your question does not determine what approach you want to take. Are you looking for something done in advance for this? If not, check out this set of graphing guides in C # (however, the same concepts can apply to any OO language). http://msdn.microsoft.com/en-us/library/ms379574.aspx

0
source

All Articles