Graphs cs320

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

What is an undirected graph?

A graph where edges do not have direction; each edge (u, v) is bidirectional.

2
New cards

What is a directed graph?

A graph where each edge (u, v) has a direction, from u to v.

3
New cards

What are nodes and edges?

Nodes (vertices) are the entities in the graph; edges represent connections between nodes.

4
New cards

What are n and m in a graph?

n = number of nodes; m = number of edges.

5
New cards

What is an adjacency matrix?

An n x n matrix where A[u][v] = 1 if there is an edge from u to v.

6
New cards

What is an adjacency list?

An array of lists, where each index stores the neighbors of a node.

7
New cards

Which graph representation is more space-efficient?

Adjacency list, especially for sparse graphs.

8
New cards

What is a path in a graph?

A sequence of nodes where each consecutive pair is connected by an edge.

9
New cards

What is a cycle in a graph?

A path where the first and last nodes are the same, and all other nodes are distinct.

10
New cards

What is a connected graph?

A graph where there is a path between every pair of nodes.

11
New cards

What is a tree in graph theory?

A connected undirected graph with no cycles.

12
New cards

How many edges does a tree with n nodes have?

n - 1

13
New cards

What is breadth-first search (BFS)?

A traversal method that explores neighbors layer by layer using a queue.

14
New cards

What is depth-first search (DFS)?

A traversal method that explores deeply along branches before backtracking, usually with a stack.

15
New cards

What is the time complexity of BFS or DFS (adjacency list)?

O(m + n)

16
New cards

What is a connected component?

A set of nodes such that each is reachable from the others.

17
New cards

How to find all connected components in a graph?

Repeatedly run BFS or DFS on unvisited nodes.

18
New cards

What is a bipartite graph?

A graph that can be 2-colored such that no edge connects same-colored nodes.

19
New cards

What prevents a graph from being bipartite?

An odd-length cycle.

20
New cards

What is a strongly connected directed graph?

Every node is reachable from every other node.

21
New cards

How to test strong connectivity?

Run BFS from a node in both original and reversed graph. If all nodes are reached, it's strongly connected.

22
New cards

What is a DAG?

A directed acyclic graph—contains no directed cycles.

23
New cards

What is topological ordering?

An ordering of nodes where each directed edge (u, v) has u before v.

24
New cards

Does every DAG have a topological ordering?

Yes.

25
New cards

What is a source in a DAG?

A node with no incoming edges.

26
New cards

What is a sink in a DAG?

A node with no outgoing edges.

27
New cards

What is the time complexity of topological sorting via in-degrees?

O(m + n)