Complete the code to declare a graph vertex as an integer identifier.
int vertex = [1];The vertex is represented as an integer identifier, so assigning 1 is correct.
Complete the code to add an edge between two vertices in an undirected graph.
graph.AddEdge([1], 2);
Edges connect vertices by their integer ids; 1 is a valid vertex id.
Fix the error in the code to correctly represent a directed edge from vertex 1 to vertex 2.
graph.AddEdge([1], 2, directed: true);
The vertex id must be an integer, so 1 is correct. Using a string causes an error.
Fill both blanks to create a weighted edge from vertex 3 to vertex 4 with weight 10.
graph.AddEdge([1], [2], weight: 10);
The edge goes from vertex 3 to vertex 4 with weight 10, so use 3 and 4.
Fill all three blanks to create a weighted, directed edge from vertex 7 to vertex 8 with weight 15.
graph.AddEdge([1], [2], weight: [3], directed: true);
The edge starts at vertex 7, ends at vertex 8, with weight 15 and is directed.
