Graph Overview
Notes
- A graph is a mathematical structure that shows relationships between items.
- Normally the items are stored in a vertex.
- Normally the relations are edges between these vertexes
- An edge can be
- undirected or directed
- weighted or unweighted
- A graph then is a set of edges and vertexes: G = (V,E)
- If there is an edge between two vertexes, then the vertexes are adjacent
- A graph with few connections is called sparse or |E| ≈ |V|
- A dense graph has many connections or |E| ≈ |V|2
- How can we store a graph?
- In an adjacency list format each vertex has a list of adjacent vertexes and possibly the cost of each edge.
- This has |E| storage requirement.
- In an adjacency matrix format a 2d array stores this information
- This has |V|2 storage requirement