Python DSA

Graphs

Graph data structure

Graphs

A graph is a data structure consisting of nodes (vertices) and edges connecting them.

Graph Representation

graph = {
    'A': ['B', 'C'],
    'B': ['A', 'D'],
    'C': ['A', 'D'],
    'D': ['B', 'C']
}