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']
}
Graph data structure
A graph is a data structure consisting of nodes (vertices) and edges connecting them.
graph = {
'A': ['B', 'C'],
'B': ['A', 'D'],
'C': ['A', 'D'],
'D': ['B', 'C']
}