A walk is the most general definition of how we can move around a graph. If we start at a vertex and then move along an edge to a new vertex, we are starting a walk. If we have a directed graph, we move in the direction of the arrows.
We can continue the walk by selecting another edge coming out of the second vertex, then a third edge coming out of the third vertex, and so on.
In a simple graph, we can represent a walk by a sequence of vertices.
If a walk starts and ends at the same vertex then it is closed, and if it starts and ends at different vertices then it is open. The walk marked on the diagram above is an open walk.
Select the valid walk in this network:
State a closed walk for the graph, starting from H with 3 edges.
A walk is the most general definition of how we can move around a graph. If we start at a vertex and then move along an edge to a new vertex, we are starting a walk. If we have a directed graph, we move in the direction of the arrows.
If a walk starts and ends at the same vertex then it is closed, and if it starts and ends at different vertices then it is open.
We record a walk by listing the vertices in order that we pass them. e.g. H, \, X, \, Y, \, H
If a walk does not use the same edge more than once, then it is a trail - it is an open trail if it’s open and a closed trail (also called a circuit) if it is closed. Here is one of each on the same graph:
The blue walk A,\,D,\,F,\,E,\,D,\,G,\,C,\,F on the left is an open trail, since no edge is used more than once, and it is open. The red walk G,\,C,\,F,\,E,\,D,\,F,\,A,\,D,\,G on the right is a closed trail (circuit), since no edge is used more than once, and it is closed.
A trail is a walk where no edge is repeated.
An open trail starts and ends on different vertices.
A closed trail (circuit) starts and ends on the same vertex.
All trails are walks and all circuits are closed walks.
Which of the following is a circuit in the network shown?
State the shortest possible closed trail that starts at H.
A trail is a walk where no edge is repeated.
An open trail starts and ends on different vertices.
A closed trail (circuit) starts and ends on the same vertex.
All trails are walks and all circuits are closed walks.
If a walk does not use the same vertex more than once (other than at the start and end) we call it a path. When a path begins and ends at the same vertex it is a closed path, which is usually called a cycle.
Here are two different paths on the same graph:
The open path on the left is D,\,G,\,C,\,F,\,E,\,A, and the closed path (called a cycle) on the right is B,\,C,\,F,\,D,\,E,\,A,\,B.
A path is a walk where no vertex is repeated (which also means that no edges can be repeated).
An open path starts and ends on different vertices.
A closed path (cycle) starts and ends on the same vertex.
All paths are walks (and trails) and all cycles are closed walks (and closed trails).
Consider the network below:
Find a path that starts at H, visits two other vertices, and then reaches B.
Now find a path that starts at H, visits four other vertices, and then reaches B.
Starting with vertices P,\,R,\,T, state the longest possible closed trail for the graph.
A common problem posed in networks is to find the path of lowest weight between two vertices. For example, finding the best (fastest, shortest, cheapest) route between two destinations.
In theory, when trying to find the shortest path by observation we should check every path and its length. However, we can eliminate some options as possibilities by looking at the structure of the network carefully first. Firstly, recall no path will pass through the same vertex or use the same edge more than once. Also, the shortest path will not take "the long way around". For our example above the shortest path would never use the section C,\,E,\,D (which take 6 minutes) when the path could flow directly from C to D in just 1 minute.
We can perform the same sort of analysis on directed graphs as well, just be careful to follow the direction on the arrows when forming paths.
For directed networks you can use a systematic approach by branching out from the start node and finding the shortest way to get to each node by progressively labelling the network until you reach the destination node.
In general, when solving shortest path problems, using trial and error is an appropriate method. However, we need to be careful as it can sometimes be difficult to ensure all paths are checked. Systematically recording the paths and eliminating paths that contain extended detours from the shortest path found so far can help avoid missing possible solutions and is effective for finding the shortest path on networks that are relatively small or not overly complex.
For larger, more complex networks, and when using technology to solve such problems a fully systematic approach is required. One such approach called Dijkstra's algorithm is explored in the investigation for this chapter. After examining this algorithm it is worth revisiting the shortest path problems from this exercise with a different approach.
The following map shows all possible routes in Mohamad's town. Mohamad travels from his home to his friend's house on a daily basis.
To solve shortest path problems, at each vertex, we should choose the edge with the smallest weight avoiding paths that contain extended detours from the shortest path.