Per our frontend application's need, we need to be able to k-expand a graph node by a user specified number of degree
One of the distinguishing feature of Graph Database compared to traditional databases such as MySQL is its ability to find relationships between data much easier in a much natural way. K-expand is one of such killing features (We will see more in the coming tasks đ)
The k-expand we are talking about here is the same thing as the Neo4J's expand operation shown below:
For example, this is a 1-degree (k = 1) expand on "nÀmlich":
[!TIP]
The semantics of the graph below is on German language. It says:
The German word "nÀmlich" has 3 dictionary meanings: same, namely, because
This is a 2-degrees (k = 2) expand on "nÀmlich":
[!TIP]
There is another German word "denn" that can also mean "because" and "Dasselbe" also means "same"
Because the database does not found a asynomy for "nÀmlich" on "namely", we see no further expansion on the "namely" node
You get the idea.
The endpoint should be able to allow us to query any graph node with an arbitrary number of expansion. Note that a node expands to another node as long as there is at least one relationship between the two nodes (ignoring relationship direction, type, values, or whatever)
[!IMPORTANT]
What is the range of k?
In some application domain, such as social network, k is pretty small. But we are going beyond that for sure. The precise range is hard to estimate at this moment, but in our database, we have a max k of 6 ~ 10 with each node expands to 3 ~ 5 neighboring nodes.
That being said, having a k of 10,000 is very unlikely, but few 10s~ would be the most probable in the future.
Viewing Our Production Data in Docker
In addition, I've made a Docker image that allows us to see our production data through Neo4J browser. Follow the steps below to see what our production data looks like:
We are good to go. We can read and write however we want. For example, here is the k-expand (unlimited k) query that expands "nÀmlich":
MATCH (term:Term{name:'nÀmlich'})
CALL apoc.path.expand(term, "RELATED|DEFINITION", null, 1, -1)
YIELD path
RETURN path, length(path) AS hops
ORDER BY hops;
We should be seeing some graph similar to the following:
Goal
Per our frontend application's need, we need to be able to k-expand a graph node by a user specified number of degree
One of the distinguishing feature of Graph Database compared to traditional databases such as MySQL is its ability to find relationships between data much easier in a much natural way. K-expand is one of such killing features (We will see more in the coming tasks đ)
The k-expand we are talking about here is the same thing as the Neo4J's expand operation shown below:
For example, this is a 1-degree (k = 1) expand on "nÀmlich":
This is a 2-degrees (k = 2) expand on "nÀmlich":
You get the idea.
The endpoint should be able to allow us to query any graph node with an arbitrary number of expansion. Note that a node expands to another node as long as there is at least one relationship between the two nodes (ignoring relationship direction, type, values, or whatever)
Viewing Our Production Data in Docker
In addition, I've made a Docker image that allows us to see our production data through Neo4J browser. Follow the steps below to see what our production data looks like:
Pull the image and start container:
When container starts, access neo4j through browser at http://localhost:7474
Connect to the database:
We are good to go. We can read and write however we want. For example, here is the k-expand (unlimited k) query that expands "nÀmlich":
We should be seeing some graph similar to the following: