List of all paths DAG?

(Bi Y Tcc K Ciu) #1

Hi all.

I have a large oracle database that I am importing as part of a GDPR cleanup , each table in oracle is a Label in neo4j with the fields of the table as properties in the Label.

I desire to join the Labels (one created in the db for each row) on keys (id to fk_id)

Using the bulk import function (so far so good with help on this board already given)

However, when its imported in (and its > 100 Label types) I'd like to be able to list all Paths from Parents to Children (DAG style)

In the 'Use the Import Tool' there are example files and if I run call db.schema() i get the three labels

Actor Movie and Sequel

Actor being the parent to the two other labels.

I would expect if I clicked text or table that I would get

Actor, ACTED_IN , Movie
Actor, ACTED_IN, Sequel

but I dont.

Considering that my db will have many more nodes joined in a long path and have paths of varying length

Can someone recommend me a process to print from the schema all possible paths in that meta graph?

(also, can I deselect Labels I dont want appearing in that call db.schema() ? )

Once again, appreciate any help anyone can give.

(M. David Allen) #2

As a starting query, you can do something like this:

MATCH p=(a:Something)-[r:*]->(b:SomethingElse)
RETURN p ORDER BY length(p)

This will return every path in the database that goes from a Something to a SomethingElse.

Be aware that this is a big request, you're probably requesting most of the contents of the database, if not all of them. So this could be a very large transaction which you might want to batch or otherwise constrain if you have a lot of data.

There will also be a lot of duplicate paths. If there is more than one way to go from a....b then you'll get both ways in this output. Additionally, if you have a graph that has, for example A -> B -> C -> D, then you'll get many paths output. First one A -> B, then A -> B -> C, then B -> C, then A -> B -> C -> D, and so on. This is why constraining the query with labels on the heads and tails, and also other criteria is important to prevent your results from blowing up.

(Bi Y Tcc K Ciu) #3

The database is huge.. hence i went to the db.schema() . function as that lists the 'meta' data.

Is there really no option to text print the links on the resulting the db.schema() meta graph?

Although my database is not in the billions, it is in the order of > 20 million nodes < 30 million and > 300million relationships.

So I think any query I write that returns all paths I think might go awry.

(M. David Allen) #4

I misunderstood. If you're looking for all paths through the metadata, please take a look here:

(Bi Y Tcc K Ciu) #5

I'll take a look though at casual glance it will only return constrained paths not all types.. but maybe I have misread it (quickly going through it).

Cheers for the push in that direction though.

(Michael Hunger) #6

If I understand you correctly does that mean the import tool didn't import relationships?

Did you specify them? How exactly did you run the import?

There is no "parent-child" relationship between labels (one could infer it if needed though).

(Bi Y Tcc K Ciu) #7

I think I am super bad at explaining. No, I managed to import relationships. So the call to db.schema() works. And using the examples movie graph I can see three nodes connected by two 'acted in' relationships...

{"name":"Keanu Reeves","personId":"keanu"} {"role":"Neo"} ("title":The Matrix.......... etc .... etc

(which I can get if I run 'Match (n:Actor)-[r]->(s) Return * Limit 25')

But the call to db.schema does not show me this.......If I need to write out the paths myself, it negates the point, as thats what I want to find out. (the paths) ..

I would have expected similar when clicking text in db.schema or at least a text representation of the meta graph.

"Actor" "acted_in" "Movie"
"Actor" "acted_in" "Sequel"

(Michael Hunger) #8

You could use the or apoc.meta.schema procedures for that. And massage the results.

This project might be interesting for you.

For an interactive meta-graph to cypher patterns, a colleague is working on a tool for that.