Chapter 18 — Graphs

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:09 PM on 7/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

46 Terms

1
New cards
Graph
A data structure made of vertices connected by edges
2
New cards
Vertex
A point or node in a graph
3
New cards
Edge
A connection between two vertices
4
New cards
Adjacent vertices
Vertices that are directly connected by an edge
5
New cards
Path
A specific sequence of edges used to get from one vertex to another
6
New cards
Graph relationship
The connection between data points inside a graph
7
New cards
Social network graph
A graph where people are vertices and friendships are edges
8
New cards
Recommendation graph
A graph where products are vertices and similar-product recommendations are edges
9
New cards
Map graph
A graph where locations are vertices and roads or routes are edges
10
New cards
Undirected graph
A graph where connections go both ways
11
New cards
Directed graph
A graph where connections have a specific direction
12
New cards
Weighted graph
A graph where edges have values such as distance, price, cost, or time
13
New cards
Weight
The value assigned to an edge in a weighted graph
14
New cards
Why weighted graphs matter
They let connections represent more than just “connected” or “not connected”
15
New cards
Graph in code
A graph can be represented by vertices that store their adjacent vertices
16
New cards
Adjacency list
A graph representation where each vertex stores a list of its neighboring vertices
17
New cards
Weighted graph in code
A graph where each vertex stores adjacent vertices and edge weights, often using a hash table
18
New cards
Graph search
Exploring a graph to find a vertex, check a connection, or traverse all vertices
19
New cards
Why search a graph
To find a vertex, check whether vertices are connected, or visit every vertex
20
New cards
Visited set
A set used to track which vertices have already been visited
21
New cards
Why visited tracking matters
It prevents infinite loops and repeated work in graphs with cycles
22
New cards
Depth-First Search
A graph search that goes as deep as possible down one path before backtracking
23
New cards
DFS
Depth-First Search
24
New cards
DFS memory trick
Go deep first, then backtrack
25
New cards
DFS use case
Useful for exploring a path fully before trying other paths
26
New cards
Breadth-First Search
A graph search that explores all nearby vertices before moving farther away
27
New cards
BFS
Breadth-First Search
28
New cards
BFS memory trick
Explore level by level
29
New cards
BFS use case
Useful for finding the shortest path in an unweighted graph
30
New cards
Queue in BFS
BFS uses a queue to process vertices in the order they are discovered
31
New cards
Stack or recursion in DFS
DFS can use recursion or a stack to go deep before backtracking
32
New cards
Graph search Big O
O(V + E)
33
New cards
V in O(V + E)
The number of vertices in the graph
34
New cards
E in O(V + E)
The number of edges in the graph
35
New cards
Why graph search is O(V + E)
The search may visit every vertex and examine every edge
36
New cards
Why not O(V + 2E)
Big O drops constants, so V + 2E becomes O(V + E)
37
New cards
Shortest path in an unweighted graph
The path with the fewest number of edges or connections
38
New cards
Shortest path in a weighted graph
The path with the lowest total weight, such as lowest cost or shortest distance
39
New cards
Dijkstra’s Algorithm
An algorithm used to find the shortest path in a weighted graph
40
New cards
Dijkstra use case
Finding the cheapest, shortest, or lowest-cost path through a weighted graph
41
New cards
Cheapest known prices table
A table Dijkstra uses to track the best known cost from the starting vertex to other vertices
42
New cards
Previous stopover table
A table Dijkstra uses to rebuild the final shortest path
43
New cards
Unvisited vertices
Vertices that Dijkstra has not fully processed yet
44
New cards
Dijkstra with array efficiency
Can be O(V²) in the simple implementation from the guide
45
New cards
Dijkstra optimization
A priority queue can make some implementations faster
46
New cards
Main lesson of Chapter 18
Graphs model relationships, and graph algorithms help search connections and find efficient pat