arturo-lang / grafito

Portable, Serverless & Lightweight SQLite-based Graph Database in Arturo
MIT License
143 stars 7 forks source link

Add support for reverse edge filters #30

Closed drkameleon closed 10 months ago

drkameleon commented 10 months ago

Let's take the famous sample11.art.

So..., we have a graph with actors, where they are from, which countries they have acted in, etc.

Right now, to get e.g. the Person(s?) that has directed the Movie with the title "Mystic River" we could perform the following query:

Screenshot 2023-11-02 at 12 00 38

And the results are the ones we'd expect.

Now, given that directed is an edge that goes from a Person ➡ to a Movie, querying like this is fine.

But what if we want the reverse thing? For example: find the Movie's that were directed by a given Person?

One way would be to make the edge bi-directional (in a few words: "Mystic River" pointing ➡ to Eastwoord and Eastwood pointing back ⬅️ to "Mystic River"). But that completely defeats the purpose of having direction-aware edges and the meaningfulness of it all.

So, basically, right now, there is simply no way to - elegantly - perform this type of seemingly ultra-logical query.

So? Let's find a way! 🚀

drkameleon commented 10 months ago

And... 💣 :

Screenshot 2023-11-02 at 13 57 32

It worked! 😄 🚀


For future reference, the way to make it work like that (reverse an edge filter) - at least for now:

drkameleon commented 10 months ago

Ready to merge! 🚀