You can follow a line of dots.
Imagine a map of dots and lines.
Imagine a map made of dots and lines. In math, we call these dots vertices. The lines are called edges.
You can move along these lines. A trip from dot to dot is a walk. A trail is a special walk. In a trail, you use each line only once. A path is even more special. In a path, you never visit the same dot twice.
Some paths are very important. A Hamiltonian path visits every single dot in the graph. You can also look for the shortest path. This is the quickest way to get from one dot to another. We can measure the distance between dots using these paths. The diameter is the largest distance between any two dots in the graph.
Some lines have values. We call these weights. The weight of a path is the sum of its line weights. Finding the shortest path is often easy for computers. Finding the longest path can be much harder. Different sets of steps, called algorithms, help us find these paths.
Imagine a map made of dots and lines. In math, we call these dots vertices. The lines are called edges.
There are special ways to move through these graphs. A trail is a walk where you use every edge only once. A path is a special kind of trail. In a path, you never visit the same vertex twice. This means all the vertices and edges are distinct. Some people call this a simple path. If a graph has edges that go in one direction, we call it a directed graph. In these, a directed path must follow the arrows in the same direction.
Some paths have very special names. A Hamiltonian path is a path that visits every single vertex in the graph. You might also look for an induced path. This is a path where no other edges connect the vertices in the path. We can also talk about how paths relate to each other. Two paths are vertex-independent if they do not share any internal vertices. They are edge-independent if they do not share any edges.
We can also measure these paths with numbers. Some graphs have weights on their edges. A weight is a value like a cost or a length. To find the weight of a path, you add up the weights of its edges. We use these weights to find the shortest path between two dots. The distance is the length of that shortest path. The diameter of a graph is the largest distance between any two vertices.
Finding these paths can be a hard job for computers. Finding the shortest path is usually much easier than finding the longest one. There are special sets of steps called algorithms to help us. Dijkstra's algorithm finds shortest paths in graphs with non-negative weights. The Bellman-Ford algorithm works even if there are negative edge weights. The Floyd-Warshall algorithm finds shortest paths between all pairs of vertices. These tools help us understand how everything is connected.
In the field of graph theory, a path is a fundamental way to describe movement through a network. A graph is made of points called vertices and lines called edges. A path is a specific sequence of these edges that connects a sequence of vertices. In most definitions, a path requires that every vertex in the sequence is distinct. Because the vertices are unique, the edges used to connect them must also be unique. This concept allows mathematicians to study how different points in a system are linked together.
To understand a path, one must first understand the concept of a walk. A walk is a finite or infinite sequence of edges that joins a sequence of vertices. A walk is considered closed if the starting vertex and the ending vertex are the same. If they are different, the walk is called open. We can also have a semi-infinite walk, which is called a ray. A ray has a starting vertex but no ending vertex. A walk can also be infinite if it has neither a first nor a last vertex.
There are important distinctions between walks, trails, and paths. A trail is a type of walk where every edge used is distinct. A path is even more restrictive; it is a trail where every vertex is also distinct. Some mathematicians use the term "simple path" to describe a path where all vertices are unique. In a directed graph, edges have a specific direction. A directed walk, trail, or path must follow these edges in the same direction. A directed path is specifically a directed trail where all vertices are distinct.
Graphs can also be weighted, meaning every edge has an associated value. This value is often called a weight, a cost, or a length. To find the weight of a walk, trail, or path, you simply sum the weights of all the edges traversed. This allows us to measure the "size" of a trip through the graph. If a graph is connected, it means there are paths that contain every possible pair of vertices. In a directed graph, we use the term "strongly connected" if there are oppositely oriented directed paths between every pair of vertices.
Certain paths have very specific names based on their properties. A Hamiltonian path is a path that includes every single vertex in the graph without any repeats. An induced path is a path where no edges in the graph connect two vertices unless they are consecutive in the path. We can also compare how paths interact with one another. Two paths are vertex-independent, or internally vertex-disjoint, if they share no internal vertices or edges. Two paths are edge-independent, or edge-disjoint, if they share no edges at all.
Paths are also used to define the physical dimensions of a graph. The distance between two vertices is defined as the length of the shortest path between them. If no path exists, the distance is considered to be infinity. The diameter of a connected graph is the largest distance found between any two vertices in that graph. These measurements help us understand the scale and reach of a network.
Finding these paths is a major area of study in computer science. There is a big difference in difficulty between finding the shortest path and the longest path. Finding the shortest path is computationally much easier than finding the longest one. Several famous algorithms exist to solve these problems. Dijkstra's algorithm finds shortest paths from a single source to all other vertices in graphs with non-negative weights. The Bellman-Ford algorithm is useful because it can handle directed graphs with negative edge weights. Finally, the Floyd-Warshall algorithm finds the shortest paths between all possible pairs of vertices in weighted directed graphs.
🖼️ Images & Media (2)
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
What is Nepedia?
A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.