Graph
The Saint-Lazare Station, 1877, Claude Monet
1. What is Graph?
Graphs are collections of things and the relationships or connections between them.
The data in a graph are called nodes or vertices.
The connections between the nodes are called edges.
2. Type of Graph
Undirected and Directed
Undirected graphs are graphs without any direction on the edges between nodes.
- ex) social network
Directed graphs are graphs with a direction and its edges.
- ex) internet and web page links. The nodes are web pages and the directed edges are links to other pages.
3. Graph Representation
3.1 Adjacency List
Adjacency List associates each vertex in the graph with the collection of its neighboring vertices or edges.
3.2 Adjacency Matrix
Adjacency Matrix is a two-dimensional array where each nested array has the same number of elements as the outer array. So it’s basically a matrix of numbers where the numbers represent the edges.
3.3 Incidence Matrix
Adjacency Matrix use both rows and columns to represent nodes.
But Incidence Matrix uses roads to represent nodes and the columns to represent edges. This means that we can have an uneven number of rows and columns. Each column will represent a unique edge. Also, each edge connects two nodes to show that there is edge between two nodes.
https://www.freecodecamp.org/
https://www.codesdope.com/
https://algorithmtutor.com/
https://blog.penjee.com/learnprogramming/programming-gifs/
https://dev.to/abdisalan_js/4-ways-to-traverse-binary-trees-with-animations-5bi5
https://www.programiz.com/