Mastering the Spanning Tree Protocol
Graph Theory Basics
What is a Graph?
Think of a graph as a simple map. It's not a chart showing data, but a collection of locations and the paths between them. In computer science and math, we use graphs to represent all sorts of networks, from friendships on social media to road systems connecting cities.
Every graph is made of two basic things: vertices and edges.
Vertex
noun
A point or node in a graph. In our map analogy, a vertex would be a city.
A single graph can have many vertices. They're the fundamental objects we're connecting.
Edge
noun
A line that connects two vertices. An edge represents a relationship or path. In our map, an edge is a road between two cities.
Here's what a simple graph looks like. We have five vertices (the circles) and several edges (the lines) connecting them.
Connected vs. Disconnected
A graph can be either connected or disconnected. The difference is straightforward.
In a connected graph, you can get from any vertex to any other vertex by following the edges. It’s like a road network where there are no isolated towns; you can always find a route from one place to another.
In a disconnected graph, there are at least two vertices with no path between them. Imagine an island with a few towns and no bridge to the mainland. The towns on the island form one part of the graph, and the towns on the mainland form another. You can't travel between them, so the overall graph is disconnected.
Trees and Spanning Trees
A tree is a special kind of connected graph. It has one critical rule: it cannot contain any cycles. A cycle is a path of edges and vertices that starts and ends at the same vertex, forming a loop. Think of a family tree—it branches out, but you never loop back to an ancestor through a different path.
A tree is a connected graph with no cycles.
This no-cycles rule is important because it means there's only one unique path between any two vertices in a tree. This makes trees very efficient and predictable for connecting things.
Now, let's talk about a spanning tree. Imagine you have a connected graph with lots of redundant paths and cycles, like a city with a complex grid of roads. A spanning tree is a subgraph that connects all the original vertices together using the fewest possible edges, creating a tree in the process. It's like picking just enough roads to keep every part of the city connected, but with no circular routes.
A single graph can have many different spanning trees. The key is that each one includes all the vertices and contains just enough edges to keep everything connected, without any loops. This concept is fundamental to how network devices prevent broadcast storms by logically disabling redundant paths.
Now that you understand the basics of graphs, let's test your knowledge.
In the context of computer science, what are the two fundamental components that make up a graph?
Which of the following scenarios best describes a disconnected graph?
Understanding these core ideas—vertices, edges, connectivity, and trees—is the first step to seeing how networks are designed to be both resilient and efficient.