Authored by Tony Feng
Created on March 29th, 2022
Last Modified on March 29th, 2022
Understanding Graphs
Main Concepts
- A Graph is a non-linear data structure consisting of nodes and edges.
- The nodes are sometimes also referred to as vertices.
- The edges are lines or arcs that connect any two nodes in the graph.
- Representations of Graphs G(V,E)
- A collection of vertices V
- A collection of edges E, represented as ordered pairs of vertices (p,q)
Graph Classifications
- Directed Graphs
- Undirected Graphs
- Weighted Graphs
Graph Terminology
- Adjacency
- A vertex is said to be adjacent to another vertex if there is an edge connecting them.
- Path
- A sequence of edges that allows you to go from vertex A to vertex B is called a path.
Operations
- Check if the element is present in the graph
- Graph Traversal
- Add elements(vertex, edges) to graph
- Finding the path from one vertex to another
Implementations
This part will be dicussed when solving the problem.
Reference
- GreeksforGreeks - Graph Data Structure And Algorithms
- Graph Data Stucture
- 手把手带你刷Leetcode力扣 - 图 Graph