What Is a Graph? Nodes, Edges, and Basic Terminology
What you'll learn: You'll understand what graphs are in machine learning, how they're built from nodes and edges, and the key types you'll encounter.
Core Idea
A graph is a mathematical structure that represents relationships between objects. Think of it like a social network: people are points, and friendships are connections between them.
Formally, a graph consists of:
- Nodes (or vertices): The individual entities in your graph (people, molecules, web pages, words)
- Edges (or links): The connections between nodes (friendships, chemical bonds, hyperlinks, co-occurrences)
Key Graph Types
Directed vs Undirected
- Undirected graphs: Edges have no direction. If A connects to B, then B automatically connects to A (like mutual friendship on Facebook)
- Directed graphs: Edges have direction, shown with arrows. A→B doesn't mean B→A (like Twitter follows: you can follow someone who doesn't follow you back)
Weighted vs Unweighted
- Unweighted graphs: All edges are equal (you're either friends or not)
- Weighted graphs: Edges carry values representing strength, distance, or cost (how often you message each friend, or the distance between cities)
Why Graphs Matter in ML
Real-world data often has relational structure: molecules, citation networks, recommendation systems, knowledge graphs, protein interactions. Traditional neural networks expect grids (images) or sequences (text), but Graph Neural Networks let us learn from these interconnected structures directly.
Key Takeaway: Graphs are collections of nodes (entities) connected by edges (relationships), and can be directed/undirected and weighted/unweighted depending on whether connections have direction and strength.