Graph Theory37 sections · 1633 units
Open in Course

LeetCode 785 Is Graph Bipartite? - Input Format

Adjacency list

The input is already an adjacency list. graph[i] gives you all neighbors of node i directly. No need to build the graph yourself. For example, if graph = [[1,3],[0,2],[1,3],[0,2]], then: - Node 00 connects to nodes 11 and 33 - Node 11 connects to nodes 00 and 22 - Node 22 connects to nodes 11 and 33 - Node 33 connects to nodes 00 and 22 This is a 44-cycle: 00-11-22-33-00.

Since 44 is even, this graph should be bipartite.