BeginnerTopic 25 of 104Software & Computing
Graphs
Vertices and edges model networks; stored as adjacency lists or matrices.
In depth
A graph has vertices and edges (directed or undirected, weighted or not). Representations: adjacency list (O(V+E) space) and adjacency matrix (O(V²)). Graphs model networks, maps, dependencies and social connections. Properties: connectivity, cycles, degree.
Key points
- Directed acyclic graphs
- Sparse vs dense
- Bipartite graphs
ExampleCities as vertices and roads as weighted edges form a road network.
Graphs model relationships between things, and they are used for maps, networks, dependencies and social systems.
What is Graphs?
Vertices and edges model networks; stored as adjacency lists or matrices.
Why is it important to understand graphs?
Graphs model relationships between things, and they are used for maps, networks, dependencies and social systems.
How are graphs stored?
As adjacency lists, which are efficient for sparse graphs, or adjacency matrices, which give fast edge checks for dense graphs.
What is the difference between directed and undirected graphs?
In a directed graph each edge has a direction, such as one-way roads, while undirected edges go both ways, such as two-way links.
How is Graphs used in practice?
Typical applications include modelling a road network for route planning, representing the dependencies between software modules in a build and describing a power grid as nodes and lines for analysis.
What should I learn before Graphs?
Study "Heaps and priority queues" first (topic 24 of 104 in Software & Computing). It covers the groundwork this topic builds on.
What are the key points of Graphs?
Directed acyclic graphs. Sparse vs dense. Bipartite graphs.
Can you give an example of Graphs?
Cities as vertices and roads as weighted edges form a road network.
What comes after Graphs?
The next topic is "BFS and DFS", which builds directly on this one.
How difficult is Graphs?
It is classed as Beginner in Software & Computing (topic 25 of 104). It is an entry-level topic. It relies only on basic school mathematics and the ideas introduced earlier in this discipline.