Thursday, June 20, 2024

10 Interview Questions on Cypher Queries and Knowledge Graph Using Neo4j (For Data Scientist Role) - Jun 2024

To See All Interview Preparation Articles: Index For Interviews Preparation
Question 1: Write a CREATE query having the following nodes and the relationship from ROOT to other nodes is 'HAS_CHILD'.

ROOT 
|--BROKER
|--PROVIDER
|--MEMBER

Answer:

CREATE (root:ROOT),
       (broker:BROKER),
       (provider:PROVIDER),
       (member:MEMBER),
       (root)-[:HAS_CHILD]->(broker),
       (root)-[:HAS_CHILD]->(provider),
       (root)-[:HAS_CHILD]->(member)

~~~

Question 2: Write a DELETE query to delete all nodes and relationships in a graph. 

Answer:
MATCH (n) DETACH DELETE n

Ref

~~~

Question 3: Write a query to get a count for all nodes of a given label:

Answer:

MATCH (n:Person)
RETURN count(n) as count

Ref

~~~

Question 4: There are three EPIC nodes in my graph. 
Each node has a numerical property CUSTOM_ID.
Now, I want to retrieve the node with the largest CUSTOM_ID.

Answer:

MATCH (n:EPIC)
RETURN n
ORDER BY n.CUSTOM_ID DESC
LIMIT 1

~~~ 

Question 5: Write query to get a node by property value in Neo4j.

Answer:


MATCH (n) 
WHERE n.name = 'Mark' 
RETURN n

Ref

~~~

Question 6: Delete a node with a given property.

Answer:
MATCH (n:Person {name: 'Tom Hanks'})
DELETE n

Ref

~~~

Question 7:  Delete ONLY nodes having label of ENTITY:

Answer:

MATCH (n:ENTITY)
DELETE n

~~~

Question 8: Return number of EPIC nodes in the knowledge graph.

Answer:

MATCH (epic:EPIC)
RETURN count(epic) as count

~~~

Question 9: Write a query to get the EPIC node with largest numerical property of CUSTOM_ID. 

Answer:

MATCH (epic:EPIC)
RETURN epic
ORDER BY epic.CUSTOM_ID DESC
LIMIT 1

~~~

Question 10:
What are some of the use cases where Between Centrality Algorithm is used?

Answer:
The Betweenness Centrality Algorithm is a powerful tool used to understand the roles of nodes in a graph and their impact on the network. Here are some use cases where it finds application:

Supply Chain Risk Analysis: In supply chain processes, Betweenness Centrality helps identify critical nodes that act as bridges between different parts of the network. For example, when transporting a product internationally, it can pinpoint bottleneck nodes during cargo ship stops in intermediate ports1.

Power Grid Contingency Analysis: The algorithm is used to analyze power grid networks, identifying critical nodes that affect the flow of electricity. Due to its computational intensity, this application often requires supercomputers2.

Community Detection and Network Routing: Betweenness Centrality assists in Girvan–Newman community detection and network routing tasks. It helps find influential nodes that connect different communities or guide information flow2.

Artificial Intelligence and Skill Characterization: Skill characterization in AI relies on identifying influential nodes. Betweenness Centrality helps determine which nodes play a crucial role in spreading information or resources2.

Epidemiology and Rumor Spreading: In epidemiology, it identifies nodes that influence the spread of diseases. Similarly, it helps analyze rumor propagation in social networks1.

Transportation Networks: The algorithm is applied to transportation networks, such as road or rail systems, to find critical nodes affecting traffic flow or resource distribution1.

Remember, Betweenness Centrality is about detecting nodes that serve as bridges, allowing information or resources to flow efficiently across a graph. 

1: graphable.ai
2: computationalsocialnetworks.springeropen.com
3: nature.com

---
Tags: Database,Technology

No comments:

Post a Comment