Complete the code to declare an adjacency list as a vector of vectors in Rust.
let graph: Vec<Vec<usize>> = [1];We use vec![vec![]; 5] to create a vector with 5 empty vectors, representing adjacency lists for 5 nodes.
Complete the code to initialize an adjacency matrix for 4 nodes with all zeros.
let matrix: Vec<Vec<u8>> = vec![vec![[1]; 4]; 4];
We fill the matrix with zeros to indicate no edges initially.
Fix the error in adding an edge from node 2 to node 3 in an adjacency list.
graph[2].[1](3);
We use push to add an element to the vector representing adjacency list.
Fill both blanks to check if there is an edge from node 1 to node 2 in an adjacency matrix.
if matrix[[1]][[2]] == 1 { println!("Edge exists"); }
We check matrix[1][2] to see if an edge exists from node 1 to node 2.
Fill all three blanks to create an adjacency list for 3 nodes and add an edge from node 0 to node 2.
let mut graph: Vec<Vec<usize>> = vec![vec![]; [1]]; graph[[2]].[3](2);
We create a graph with 3 nodes, then add an edge from node 0 to node 2 using push.
