top of page
  • Writer's pictureRevanth Reddy Tondapu

Part 18: Utilizing Neo4j for Crime Investigation: A Step-by-Step Guide


Utilizing Neo4j for Crime Investigation
Utilizing Neo4j for Crime Investigation

In this blog post, we'll explore how Neo4j can be used for crime investigation use cases. Neo4j's graph database capabilities make it an excellent tool for uncovering relationships and patterns within complex datasets. We'll walk through a practical example using sample crime investigation data.


Setting Up the Environment

First, let's set up our Neo4j environment and import the investigation sample data. We'll do this step by step.


Step 1: Access the Neo4j Sandbox

  1. Open the Neo4j Sandbox: Navigate to the Neo4j Sandbox platform in your browser.

  2. Create a New Project: Click on the option to create a new project.


Step 2: Import Crime Investigation Sample Data

  1. Choose a Dataset: Select the crime dataset from the available options.

  2. Import Data: Follow the prompts to import the sample data into your new project. This may take a few minutes depending on the size of the dataset.


Step 3: Open Neo4j Browser

  1. Open the Browser: Once the data is imported, open the Neo4j Browser. This is where you'll run your queries and visualize the data.

  2. Login: Click on the sandbox login to access your project.


Understanding the Schema

To get a high-level understanding of the data schema, we run the schema visualization command:

CALL db.schema.visualization();

Schema Overview

After running the command, we observe nodes with labels such as Officer, Crime, Person, Location, and others. The relationships include:

  • A Crime is investigated by an Officer.

  • A Person is party to a Crime.

  • A Crime occurred at a Location.

  • A Person's current address is associated with a Location.

  • One Person knows another Person.

  • Other relationships include email and phone communications.

Understanding this schema is crucial for performing meaningful queries and analyses.


Crime Investigation Analysis

Let's start our analysis by finding all the crimes being investigated by an officer with the surname Larive.


Query: Crimes Under Investigation by Officer Larive

MATCH (c:Crime {last_outcome: 'Under investigation'})-[i:INVESTIGATED_BY]->(o:Officer {badge_no: '26-5234182', surname: 'Larive'})
RETURN *;

Results and Visualization

From the results, we can see that Officer DV Larive is investigating multiple crimes. To make the visualization clearer, we can add captions for the crime types and change the color as per our choice.


Focusing on Drug-Related Crimes

narrow down our analysis to the drug-related crimes being investigated by Officer Larive.


Query: Drug Crimes Under Investigation by Officer Larive

MATCH (c:Crime {last_outcome: 'Under investigation', type: 'Drugs'})-[i:INVESTIGATED_BY]->(o:Officer {badge_no: '26-5234182', surname: 'Larive'})
RETURN *;

Results

Now, we have a subset of crimes that are drug-related and under investigation by Officer Larive. These results will help us focus on specific cases for further analysis.


Expanding the Network

Next, let's expand the network by clicking on the crime nodes and exploring their connections.


Expanding Nodes

By expanding the network, we observe that two drug crimes occurred at the same location. Additionally, we find that Jack is involved in both of these crimes, which is valuable information for the investigating officer.


Further

Expanding another drug crime node reveals that Raymond is involved in this crime. As an investigating officer, it would be useful to know how Jack and Raymond are connected.


Finding Connections Between Individuals

To find the shortest path between Jack and Raymond, we use the following query:


Query:est Path Between Persons Involved in Drug Crimes

MATCH (c:Crime {_outcome: 'Under investigation', type: 'Drugs'})-[:INVESTIGATED_BY]->(:Officer {badge_no: '26-5234182'}),
(c)<-[:PARTY_TO]-(p:Person)
WITH COLLECT(p) AS persons
UNWIND persons AS p1
UNWIND persons AS p2
WITH * WHERE id(p1) < id(p2)
MATCH path = allshortestpaths((p1)-[:KNOWS|KNOWS_LW|KNOWS_SN|FAMILY_REL|KNOWS_PHONE*..3]-(p2))
RETURN path;

Explanation of the Query

  1. Match Crime Nodes:

MATCH (c:Crime {last_outcome: 'Under investigation', type: 'Drugs'})-[:INVESTIGATED_BY]->(:Officer {badge_no: '26-5234182'}),
(c)<-[:PARTY_TO]-(p:Person)
  • Finds crimes under investigation for drugs by Officer Larive.

  • Matches persons associated with these crimes.


2. Collect Persons:

WITH COLLECT(p) AS persons
UNWIND persons AS p1
WIND persons p2
  • Collects all matched persons into a list.

  • Unwinds the list to create pairs of persons for comparison.


3. Filter Pairs:

WITH * WHERE id(p1) < id(p2)
  • Filters pairs to avoid redundant comparisons and self-loops.


4. Find Shortest Paths:

MATCH path = allshortestpaths((p1)-[:KNOWS|KNOWS_LW|KNOWS_SN|FAMILY_REL|KNOWS_PHONE*..3]-(p2))
RETURN path;
  • Finds shortest paths up to three hops involving various relationships like KNOWS, FAMILY_REL, and KNOWS_PHONE.


Results

The results show that Jack and Raymond are connected through third-degree relationships with individuals like Brian, Phillip, Allen, and Kathleen as common connections. This information is useful for the investigating officer to understand the social network and familial connections between suspects.


Conclusion

In this demo, we demonstrated how Neo4j can be utilized for crime investigation. By understanding the schema, running targeted queries, and analyzing the results, we can uncover valuable insights and connections. Neo4j powerful graph database capabilities make it an excellent tool for law enforcement and investigative applications.

Key Takeaways:

  1. Schema Visualization: Understanding the data schema is the first crucial step. It helps in identifying the different entities (nodes) and their relationships.

  2. Focused Queries: By running focused queries, such as filtering crimes by type or investigating officer, we can narrow down the data to the most relevant subsets.

  3. Network Expansion: Expanding the network around specific nodes helps in understanding the broader context and identifying critical connections between different entities.

  4. Shortest Path Analysis: Finding the shortest path between individuals involved in crimes helps in understanding their relationships and potential collaborations or conflicts.

By following these steps, law enforcement agencies can leverage Neo4j to streamline their investigative processes, saving time and improving the accuracy of their investigations.

Practical Applications

The example we explored is just one of many potential applications. Here are a few more scenarios where Neo4j can be impactful:

  • Fraud Detection: Analyzing transactional data to identify fraudulent patterns and connections between suspicious accounts.

  • Terrorism Investigation: Mapping out terrorist networks and their connections to uncover plots and prevent attacks.

  • Missing Persons: Tracking the movements and connections of missing persons to find leads on their whereabouts.

  • Cybersecurity: Analyzing network logs to detect and mitigate cyber threats by understanding the connections between different entities in the network.

Final Thoughts

Neo4j provides a robust platform for complex data analysis, especially in scenarios where relationships and connections are critical. Its graph database model is intuitive and aligns closely with how real-world entities interact, making it a powerful tool for various investigative and analytical tasks.

By integrating Neo4j into your investigative toolkit, you can unlock new levels of insight and efficiency, ultimately leading to more successful outcomes in your investigations.

Thank you for following along with this demo. If you have any questions or need further assistance, feel free to reach out. Happy investigating!

7 views0 comments

Comments


bottom of page