Graphs
A graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph.
Representations
There are two common ways to represent a graph in a computer's memory:
- Adjacency Matrix: A 2D array where each element represents the presence or absence of an edge.
- Adjacency List: An array of lists, where each list contains the neighbors of a vertex.