Complete the code to declare a graph vertex as an integer variable named 'vertex'.
int [1] = 5;
The variable representing a graph vertex is commonly named vertex.
Complete the code to add an edge from vertex 1 to vertex 2 in a directed graph using adjacency list.
graph[1].[1](2);
To add an edge in adjacency list, we use the add method to insert the destination vertex.
Fix the error in the code to correctly check if an edge exists from vertex u to vertex v in an undirected graph adjacency list.
if(graph[u].contains([1])) { System.out.println("Edge exists"); }
To check if an edge exists from u to v, we check if the adjacency list of u contains v.
Fill both blanks to create a weighted edge from vertex u to vertex v with weight w using an Edge class.
Edge e = new Edge([1], [2], w);
The Edge constructor takes source vertex u, destination vertex v, and weight w. Here, we fill u and v.
Fill all three blanks to create a map of vertices to their weights using Java streams.
Map<Integer, Integer> map = list.stream().filter(edge -> edge.getWeight() > [3]).collect(Collectors.toMap([1], [2]));
We map source vertices to weights and filter weights greater than 10.
