It looks like your PRUNE statement should do the job, but you need the last 
element, so wouldn't LAST() work (instead of calling a specific )?

    RETURN LAST(path)

Alternately, this might not work out, but if you have an attribute to SORT 
on (maybe e.established ASC, so you're desired hit is first), you could 
skip the LET PATH = (..) and just RETURN v

On Wednesday, February 16, 2022 at 2:17:59 PM UTC-8 [email protected] 
wrote:

> I am not totally new to graph databases (Neo4J about a decade ago) nor 
> graph problems, but it's been a while, so forgive my ArangoDB noobie 
> perspective.
> I am trying to figure out how to determine what a place would have been 
> called in the past.  Save I have a place called "G" in the following graph:
> [image: Untitled (1).jpg]
> In this graph, places are linked by edges that tell you when the place was 
> founded from another place (so, G was founded in 600 from F).  I want to 
> query what G was called in a given year: if I ask for the name of the place 
> currently called 'G' in the year 450, the answer ought to be 'D' (because 
> not only was G founded from F in 600, but F was founded from D in 500, 
> while D was founded in 300).  I think I need to include a "root" node for 
> path traversals to come back in a consistent form (ie always include place 
> 'A' if the date is before 100).
>
> I have been trying out AQL to answer the question, with some success, but 
> am not sure this is the Right Way (tm) to go about it, so any pointers 
> would be helpful.
>
> FOR p IN places
>     FILTER p.display_name == @name
>     LET path = (
>         FOR v, e IN 0..10 OUTBOUND p places_established_from
>             PRUNE e != null AND e.established < @date
>             RETURN v
>     )
>     RETURN path[-2]
>
> It seems to do the trick but does not feel so natural nor efficient?
>
> jeff
>

-- 
You received this message because you are subscribed to the Google Groups 
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/arangodb/ecf7fb26-fedc-4652-94fa-0815180e6315n%40googlegroups.com.

Reply via email to