A vertex (or node) is a fundamental unit in a graph that represents an entity or point. It is where edges connect.
Click to reveal answer
beginner
Define an edge in graph terminology.
An edge is a connection or link between two vertices in a graph. It can represent relationships or paths.
Click to reveal answer
beginner
What is the difference between a directed and an undirected edge?
A directed edge has a direction from one vertex to another (like a one-way street). An undirected edge has no direction and connects vertices both ways (like a two-way street).
Click to reveal answer
beginner
What does it mean if a graph is weighted?
A weighted graph has edges that carry a value (weight), such as cost, distance, or time, representing the strength or cost of the connection.
Click to reveal answer
intermediate
Can a graph have both directed and undirected edges?
Yes, such graphs are called mixed graphs. They contain both directed and undirected edges connecting vertices.
Click to reveal answer
Which of the following best describes a vertex in a graph?
AA connection between two points
BA point where edges meet
CA value assigned to an edge
DA direction of an edge
✗ Incorrect
A vertex is a point or node where edges connect.
What type of edge has a direction from one vertex to another?
ADirected edge
BUndirected edge
CWeighted edge
DMixed edge
✗ Incorrect
Directed edges have a specific direction from one vertex to another.
In an undirected graph, edges are:
AOne-way connections
BAlways weighted
CTwo-way connections
DAlways directed
✗ Incorrect
Undirected edges connect vertices both ways, like two-way streets.
What does the weight on an edge represent in a weighted graph?
AA value like cost or distance
BThe direction of the edge
CThe color of the edge
DThe number of vertices
✗ Incorrect
Weights represent values such as cost, distance, or time on edges.
A graph that contains both directed and undirected edges is called:
AComplete graph
BWeighted graph
CSimple graph
DMixed graph
✗ Incorrect
Mixed graphs have both directed and undirected edges.
Explain the difference between directed and undirected edges in a graph.
Think about how traffic flows on one-way vs two-way roads.
You got /3 concepts.
Describe what a weighted graph is and why weights might be useful.
Imagine roads with distances or toll costs.
You got /3 concepts.
Practice
(1/5)
1. In a graph, what do we call the points or nodes where edges meet?
easy
A. Edges
B. Vertices
C. Weights
D. Paths
Solution
Step 1: Understand graph components
A graph consists of points called vertices and connections called edges.
Step 2: Identify the term for points
The points or nodes where edges meet are called vertices.
Final Answer:
Vertices -> Option B
Quick Check:
Points in graph = Vertices [OK]
Hint: Vertices are the dots, edges are the lines connecting them [OK]
Common Mistakes:
Confusing edges with vertices
Thinking weights are points
Mixing paths with vertices
2. Which of the following is the correct way to declare an undirected graph using adjacency list in C++?
easy
A. vector graph; graph.resize(5); // Undirected graph
B. vector> graph[5]; // Weighted graph
C. int graph[5][5]; // Undirected graph
D. vector<int> graph(5); // Undirected graph
Solution
Step 1: Understand adjacency list declaration
An adjacency list for a graph with 5 vertices can be declared as a vector of vectors and resized to 5.
Step 2: Check options for correct syntax
vector graph; graph.resize(5); // Undirected graph uses vector graph; graph.resize(5); which is correct for undirected graph adjacency list.
Final Answer:
vector graph; graph.resize(5); // Undirected graph -> Option A