What on Earth is a Knowledge Graph?
What on Earth is a Knowledge Graph?
The detective spread the photographs across the table, each one showing a different person, a different location, a different moment in time. Individually, these images told small stories. But as she connected them with red string—linking the suspect to the coffee shop, the coffee shop to the informant, the informant to the crime scene—something remarkable happened. The web of connections revealed a story that no single photograph could tell. Patterns emerged. Relationships became visible. And suddenly, what seemed like an impenetrable mystery began to unravel.
This is graph thinking. And whether you realize it or not, you've been doing it your entire life.
Now imagine if we could take that same detective's intuition—those red strings and connecting insights—and automate it. Imagine if we could build systems that understood not just isolated facts, but the relationships between those facts. Imagine a technology that could look at millions of pieces of information and immediately see the connections, the patterns, the hidden stories woven through the data.
This is what a knowledge graph does. And once you understand what it is and how it works, you'll never look at information the same way again.
The World of Connections
Let's start with something you already know intimately: your social network. Think about your Facebook friends, your LinkedIn connections, or your Instagram followers. These aren't just a list of names. Each person in your network is connected to you through some relationship—friend, colleague, family member, former classmate. And those people are connected to others, forming an intricate web of relationships that spans the entire globe.
Now, what if you wanted to find all the people in your extended network who work at the same company as your best friend's spouse? Or find the shortest path between you and a complete stranger who turns out to be a friend of a friend of a friend? In a traditional list of names, this would be nearly impossible. You'd have to manually check each person's profile, cross-reference their connections, and piece together the relationships one by one.
But in a graph, this becomes trivial. Each person is a node (also called a vertex), and each connection between them is an edge. The entire social network becomes a map of interconnected nodes, and finding connections becomes a matter of following the paths between them.
This is the fundamental insight behind knowledge graphs: relationships are as important as the entities themselves.
The Three Pillars: Nodes, Edges, and Properties
Every knowledge graph is built on three foundational concepts. Understanding these will give you the foundation you need to grasp everything else in this book.
Nodes: The "Nouns" of Your Data Universe
A node represents an entity—a thing that exists and can be described. In a knowledge graph about movies, nodes might include specific films ("The Matrix"), actors ("Keanu Reeves"), directors ("The Wachowskis"), and genres ("Science Fiction"). In a healthcare knowledge graph, nodes might include patients, doctors, medications, diseases, and hospitals.
Nodes are the nouns of your knowledge graph. They are the "who," "what," and "where" of your information universe.
Here's what makes nodes powerful: they can contain properties. A node representing "Keanu Reeves" might have properties like `born: September 2, 1964`, `nationality: Canadian`, and `occupation: Actor`. These properties provide additional context and detail about the entity, making it more useful and searchable.
Edges: The "Verbs" That Connect
If nodes are nouns, then edges are the verbs—the actions and relationships that connect them. An edge represents the relationship between two nodes. In our movie knowledge graph, we might have edges like `ACTED_IN` connecting Keanu Reeves to The Matrix, or `DIRECTED_BY` connecting The Matrix to The Wachowskis.
Edges give meaning to the connections. They answer questions like: How is this person connected to that company? What is the relationship between this drug and that disease? How did this event lead to that outcome?
The direction of an edge often matters. An edge `KNOWS` might be undirected (Alice knows Bob means the same as Bob knows Alice), but an edge `EMPLOYED_BY` is directional (Alice is employed by Company X, but Company X is not employed by Alice). Most graph systems support both directed and undirected edges, and choosing the right type is important for accurately representing your domain.
Properties: The Details That Matter
Properties (also called attributes or annotations) provide additional information about nodes and edges. They are key-value pairs that describe characteristics without establishing new connections.
For example, consider an edge representing the relationship between a movie and an actor:
``` (Movie: The Matrix)-[ROLE: Neo]->(Actor: Keanu Reeves) ```
Here, `ROLE: Neo` is a property on the edge that specifies exactly which character the actor played. Similarly, a node representing "The Matrix" might have properties like:
``` title: "The Matrix" release_year: 1999 rating: 8.7 budget: $63 million ```
Properties transform a simple network diagram into a rich, detailed knowledge structure. They give context to the relationships and allow for sophisticated queries that go beyond simple "who is connected to whom."
Why Our Brains Think in Graphs
Here's something fascinating: human memory and understanding are fundamentally graph-like in structure. When you think about "Paris," your brain doesn't just retrieve a single entry labeled "Paris." Instead, it activates a web of associated concepts—Eiffel Tower, French cuisine, the Louvre, Napoleon, romantic vacations, the Seine River, French language—and the connections between them.
This is why memory techniques often involve creating vivid, interconnected associations. The more connections you can build to a piece of information, the more firmly it's anchored in your memory and the easier it is to retrieve.
Psychologists call this "associative memory," and it's one of the most powerful aspects of human cognition. But here's the problem: most of our information systems completely ignore this insight.
Consider how you currently interact with search engines. You type in keywords—"Paris travel tips"—and you get a list of documents that contain those words. The search engine doesn't understand that you're planning a vacation. It doesn't know that you prefer museums over nightlife, or that you're traveling with young children. It simply matches keywords.
Now imagine a different kind of search. One that understands that you're a person (a node), that you're planning a trip to a city (another node), that this trip involves activities like visiting museums and restaurants (edges connecting you to those activities), and that your children have ages and interests that constrain what activities are appropriate.
This contextual, relationship-aware understanding is what knowledge graphs enable. They don't just store facts; they store the web of meaning that connects those facts.
The Detective's Intuition, Automated
Let's return to our detective scenario, but this time imagine she's working on a complex financial fraud case involving thousands of transactions, dozens of shell companies, and countless individuals across multiple countries. The traditional approach would involve:
1. Reviewing transaction records one by one 2. Cross-referencing names and addresses manually 3. Building spreadsheets to track connections 4. Creating visual diagrams by hand or with basic drawing software
This process is slow, error-prone, and nearly impossible to scale. The detective might spend weeks or months just organizing the data before she can even begin the real analysis.
Now imagine she has access to a knowledge graph system. The transactions, accounts, companies, and individua