1. Home
  2. Explore
  3. Computer Science
  4. Graph Theory Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Graph Theory Introduction

  • 55Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Graph Basics and Types
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is graph theory?

Tap to flipClick to flipspace

The study of properties and applications of graphs, which are also called networks.

Or swipe the card

55 cards

  1. What is graph theory?

    The study of properties and applications of graphs, which are also called networks.

  2. What is an undirected graph?

    A graph where edges have no orientation: an edge from u to v is identical to the edge from v to u.

  3. What is a directed graph (digraph)?

    A graph where edges have a direction: an edge from u to v allows traversal only from u to v, not vice versa.

  4. What is a weighted graph?

    A graph where edges contain weights representing arbitrary values such as cost, distance, or quantity.

  5. What is a tree in graph theory?

    An undirected graph with no cycles. Equivalent definitions: a graph with n nodes and n-1 edges.

  6. What is a rooted tree?

    A tree with a designated root node, where edges point away from (out-tree/arborescence) or towards (in-tree) the root.

  7. What is a directed acyclic graph (DAG)?

    A graph with directed edges and no cycles. Important for structures with dependencies.

  8. What is a bipartite graph?

    A graph whose vertices can be split into two independent groups U and V such that every edge connects between U and V.

  9. What is a complete graph?

    A graph where there is a unique edge between every pair of nodes. A complete graph with n vertices is denoted KnK_nKn​.

  10. What is an adjacency matrix?

    A 2D matrix where cell M[i][j]M[i][j]M[i][j] represents the edge weight from node i to node j (or 1 if unweighted). The diagonal is usually 0.

  11. What is an adjacency list?

    A representation where each node stores a list of its outgoing edges (destination and weight).

  12. What is an edge list?

    A representation as an unordered list of edges, each stored as a triplet (u, v, w).

  13. What is the shortest path problem?

    Given a weighted graph, find the shortest path (minimum total weight) from node A to node B.

  14. What is the connectivity problem?

    Determine if there exists a path from node A to node B (ignoring weights).

  15. What is a negative cycle?

    A cycle whose total edge weight is negative. In shortest path problems, it allows endlessly decreasing path cost.

  16. What are strongly connected components (SCCs)?

    Self-contained cycles in a directed graph where every vertex in a component can reach every other vertex in that component.

  17. What is the Traveling Salesman Problem (TSP)?

    Given n cities and distances between each pair, find the shortest route that visits each city exactly once and returns to the start.

  18. What is a bridge in a graph?

    An edge whose removal increases the number of connected components.

  19. What is an articulation point?

    A node whose removal increases the number of connected components.

  20. What is a minimum spanning tree (MST)?

    A subset of edges that connects all vertices together without cycles and with minimum total edge weight.

  21. What is the maximum flow problem?

    Given a flow network (source, sink, edges with capacities), find the maximum amount of flow that can be sent from source to sink without exceeding capacities.

  22. What is a depth-first search (DFS)?

    A graph traversal algorithm that explores as far as possible along each branch before backtracking.

  23. How does DFS work conceptually?

    Start at a node, mark visited, recursively explore unvisited neighbors. Backtrack when no unvisited neighbors remain.

  24. What is a breadth-first search (BFS)?

    A graph traversal algorithm that explores nodes in layers, visiting all neighbors before moving to the next level.

  25. How does BFS find the shortest path on an unweighted graph?

    By maintaining a queue and a 'prev' array to reconstruct the path. BFS visits nodes in order of their distance from the start.

  26. How to represent a grid as a graph for BFS pathfinding?

    Label cells with indices 0 to N-1. Use direction vectors (e.g., (0,1), (1,0), (0,-1), (-1,0)) to find neighbors within bounds.

  27. What is topological sort?

    An ordering of nodes in a directed acyclic graph such that for every directed edge u → v, u comes before v.

  28. How to perform topological sort using DFS?

    Run DFS from each unvisited node. On the callback (after exploring all neighbors), add the current node to the front of the ordering.

  29. How to find the shortest path on a DAG?

    Find topological order, then relax each edge in that order. Initialize dist[start]=0, others=infinity. For each node in topological order, relax its outgoing edges.

  30. How to find the longest path on a DAG?

    Negate all edge weights, find the shortest path, then negate the result.

  31. What is Dijkstra's algorithm?

    A single-source shortest path algorithm for graphs with non-negative edge weights. It greedily selects the next most promising node using a priority queue.

  32. How does Dijkstra's algorithm work?

    Maintain a distance array (initialize to infinity, start=0) and a priority queue of (node, distance). Repeatedly extract the minimum, relax its neighbors, and push updated distances.

  33. What is the Bellman-Ford algorithm?

    A single-source shortest path algorithm that can handle negative edge weights and detects negative cycles.

  34. How does Bellman-Ford detect negative cycles?

    After V−1V-1V−1 relaxation passes, run one more pass. Any node whose distance improves is part of or reachable from a negative cycle; set its distance to −infty-infty−infty.

  35. What is the Floyd-Warshall algorithm?

    An all-pairs shortest path algorithm that works on both directed and undirected graphs. It uses dynamic programming and runs in O(V3)O(V^3)O(V3).

  36. How does Floyd-Warshall work?

    Initialize distance matrix with edge weights (infinity for no edge). Then for each k, for each i, j: if dist[i][k]+dist[k][j]<dist[i][j]dist[i][k] + dist[k][j] < dist[i][j]dist[i][k]+dist[k][j]<dist[i][j], update dist[i][j]dist[i][j]dist[i][j].

  37. What is Prim's algorithm?

    A greedy algorithm to find a minimum spanning tree. It grows a tree from a start node, always adding the cheapest edge connecting the tree to a non-tree node.

  38. How does the eager version of Prim's algorithm work?

    Use an indexed priority queue (IPQ) to store the best incoming edge for each node (except start). Relax edges from the current node: if a better edge to a neighbor is found, update the IPQ.

  39. What is the Ford-Fulkerson method?

    A method to compute the maximum flow in a flow network by repeatedly finding augmenting paths from source to sink and augmenting flow along them until no more paths exist.

  40. What is an augmenting path?

    A path from source to sink in the residual graph where every edge has remaining capacity greater than zero.

  41. What is the residual graph?

    The graph that includes both original edges and backward edges (residual edges) representing the possibility to undo flow.

  42. What is Edmonds-Karp algorithm?

    An implementation of Ford-Fulkerson that uses BFS to find the shortest augmenting path (in number of edges) in each iteration.

  43. What is capacity scaling?

    A heuristic that prioritizes edges with large remaining capacity by using a threshold parameter DeltaDeltaDelta that halves each phase.

  44. What is Dinic's algorithm?

    A strongly polynomial maximum flow algorithm that uses level graphs and blocking flows to achieve O(V2E)O(V^2 E)O(V2E) time, and O(sqrtVE)O(sqrt{V}E)O(sqrtVE) on bipartite graphs.

  45. How does Dinic's algorithm build a level graph?

    Perform BFS from the source, assigning each node a level (distance). Only edges that go from level lll to l+1l+1l+1 with positive remaining capacity are included.

  46. What is a blocking flow?

    A flow in the level graph such that no more augmenting paths from source to sink exist using only edges in the level graph.

  47. How to find bridges in an undirected graph using DFS?

    Assign IDs during DFS, compute low-link values (smallest reachable ID). An edge (u, v) is a bridge if id[u]<low[v]id[u] < low[v]id[u]<low[v].

  48. How to find articulation points using DFS?

    Similar to bridges but also check for cycles: if id[u]lelow[v]id[u] le low[v]id[u]lelow[v], then u is an articulation point (except if u is root with only one child).

  49. What is Tarjan's algorithm for SCC?

    A DFS-based algorithm that uses low-link values and a stack to find strongly connected components in O(V+E)O(V+E)O(V+E).

  50. What is an Eulerian path?

    A path in a graph that visits every edge exactly once.

  51. What is an Eulerian circuit?

    An Eulerian path that starts and ends on the same vertex. Requires all vertices to have even degree (undirected) or equal in/out degree (directed).

  52. How to find an Eulerian path algorithmically?

    Verify conditions, then perform DFS, removing edges as they are used. On backtrack, add the current node to the front of a list. Use a careful ordering to avoid getting stuck.

  53. How to solve the Traveling Salesman Problem with dynamic programming?

    Use DP over subsets: let dp[mask][last]dp[mask][last]dp[mask][last] be the minimum cost to visit the set of nodes represented by mask and end at last. Base: dp[1<<start][start]=0dp[1<<start][start] = 0dp[1<<start][start]=0. Transition: dp[mask][last]=minnextinmask(dp[masksetminusnext][last]+dist[last][next])dp[mask][last] = min_{next in mask} (dp[mask setminus {next}][last] + dist[last][next])dp[mask][last]=minnextinmask​(dp[masksetminusnext][last]+dist[last][next]).

  54. How to solve unweighted bipartite matching using max flow?

    Create source and sink. Connect source to each left node with capacity 1. Connect each left node to each right node if they can be matched (capacity 1). Connect each right node to sink with capacity 1. The max flow gives the maximum matching.

  55. What is the importance of the 'Dinic' algorithm for bipartite graphs?

    Dinic runs in O(sqrtVE)O(sqrt{V}E)O(sqrtVE) on bipartite graphs, making it extremely efficient for large matching problems.

Card 1 of 55
Card 1 of 55

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent