A weighted graph is a graph in which a numerical weight is provided before each value. It is a simple graph with weighted edges defined for all values. The graph is used to calculate the shortest distance between two points. It consists of a set of vertices, edges, and weights assigned to each value.
A weighted graph has two types. It consists of:
- Directed graph
It is a graph where the edges have direction.
- Undirected graph
It is a graph where the edges have no direction. It is the same as the directed graph but has bi-directional connections between nodes.
Example of a weighted graph
Suppose you run an airline and you want an estimate of the fuel costs. For this, you will require a model that would help you estimate the fuel costs based on the route your airline travels on. In this example, the nodes will be defined as the airport, edges will represent the flights operating between the destination airports, and the edge weight could be the distance between two airports. This model can help decide the shortest route between two airports. The graph is used to measure the distance between two edges. Moreover, it can be used to measure the cost between two vertices. Sometimes, finding the maximum value is necessary to calculate the overall costs and distance. The graph can also be used to measure the maximum flow of water that an area can receive. Furthermore, it can help decide what students can do to expand their network.