Graph is an extension to binary tree (or more precisly mulitiway tree). But the only difference is that in graph, there might be cycle.
we will need to use visited set to avoid infinite loop. A graph consists of nodes (or vertices) and edges (connections between nodes). Graphs can be directed or undirected, weighted or unweighted, and can contain cycles.
We can use adjacency list or adjacency matrix to represent a graph.
It easy to switch from different type of graphs.
DFS and BFS in graphs
TODO
Will come back with more understand after solving some leetcode problems.