DSA question set · 168 questions
Graph DSA Practice Questions
Explore 168 DSA questions in Graph. Practice with DSAWiser’s code editor and visualizer.
Graph
What’s in this set
The Graph collection contains 168 problems: 56 basic, 31 easy, 46 medium, 27 hard, 8 very hard. Choose a question at your current level, or follow the collection’s order below.
Topics in this collection include Graph. Each question shows its own topics and difficulty so you can decide where to begin.
Practice with the code visualizer
- Open a question in the editor and read the statement, inputs, and expected output. Predict the result for a small example before writing code.
- Write a solution and run the examples. If a result differs from your prediction, reduce the input until you can follow each step.
- Step through your code in the visualizer. Use a breakpoint to inspect the state at a specific line, then compare it with your reasoning.
Questions in this set
168 totalOpen a question in the editor to read its statement and examples. Sign in to practice.
- Represent a Graph as an Adjacency MatrixGraphBasic
- Represent a Graph as an Adjacency ListGraphBasic
- Number of Vertices in an Adjacency MatrixGraphBasic
- Count Total Directed Edges from Adjacency MatrixGraphBasic
- Count Total Undirected Edges from Adjacency MatrixGraphBasic
- Degree of a Vertex in an Undirected Graph (Adjacency Matrix)GraphBasic
- In-Degree of a Vertex in a Directed Graph (Adjacency Matrix)GraphBasic
- Out-Degree of a Vertex in a Directed Graph (Adjacency Matrix)GraphBasic
- Find All Outgoing Neighbors of a Vertex (Adjacency List)GraphBasic
- Check if an Edge Exists in an Adjacency MatrixGraphBasic
- Convert Adjacency Matrix to Adjacency ListGraphBasic
- Convert Adjacency List to Adjacency MatrixGraphBasic
- Check for Self-Loops in an Adjacency MatrixGraphBasic
- Count Self-Loops in an Adjacency MatrixGraphBasic
- Check if a Vertex is IsolatedGraphBasic
- Find All Isolated Vertices in an Undirected GraphGraphBasic
- Check if a Vertex is a Leaf (Pendant) VertexGraphBasic
- Find All Leaf Vertices in an Undirected GraphGraphBasic
- Check if a Graph is Undirected (Symmetric Adjacency Matrix)GraphBasic
- Check if a Vertex is a Universal VertexGraphBasic
- Maximum Degree of a GraphGraphBasic
- Minimum Degree of a GraphGraphBasic
- Compute Degree Sequence of an Undirected GraphGraphBasic
- Sum of Degrees in an Undirected GraphGraphBasic
- Verify Handshaking LemmaGraphBasic
- Check if a Graph is a Complete GraphGraphBasic
- Check if a Graph is an Empty (Null) GraphGraphBasic
- Check if a Graph is k-RegularGraphBasic
- Check if a Graph is a Regular GraphGraphBasic
- Check if a Graph is a Star GraphGraphBasic
- Transpose (Reverse) of a Directed Graph (Adjacency Matrix)GraphBasic
- Transpose (Reverse) of a Directed Graph (Adjacency List)GraphBasic
- Complement of an Undirected GraphGraphBasic
- Add an Undirected Edge to an Adjacency MatrixGraphBasic
- Remove an Undirected Edge from an Adjacency MatrixGraphBasic
- Check if Two Vertices Are Adjacent (Adjacency List)GraphBasic
- Find Common Neighbors of Two VerticesGraphBasic
- Verify if a Sequence of Vertices is a Valid WalkGraphBasic
- Length of a PathGraphBasic
- Check Whether a Vertex Sequence Has RepetitionsGraphBasic
- Check Whether a Walk Is ClosedGraphBasic
- Delete a Vertex from an Adjacency MatrixGraphBasic
- Find Destinations of Two-Edge WalksGraphBasic
- Count Incoming Neighbors in an Adjacency ListGraphBasic
- Check if an Undirected Graph Has an Euler Path Precondition (Degree Parity)GraphBasic
- Convert Adjacency Matrix to Edge ListGraphBasic
- Check if a Vertex is a Universal Sink in a Directed GraphGraphBasic
- Check if a Vertex is a Universal Source in a Directed GraphGraphBasic
- Check if Graph Has Any Isolated Connected Component of Size 1GraphBasic
- Find All Leaves in a Directed Acyclic Graph (Out-Degree 0 Sinks)GraphBasic
- Find All Sources in a Directed Acyclic Graph (In-Degree 0 Sources)GraphBasic
- Verify 2-Coloring Assignment in an Undirected GraphGraphBasic
- Density of an Undirected Simple GraphGraphBasic
- Count Edges in the Complement GraphGraphBasic
- Size of Maximum Independent Set in a Star GraphGraphBasic
- Deep Copy a Graph Adjacency ListGraphBasic
- Find if Path Exists in Undirected GraphGraphEasy
- Find the Town JudgeGraphEasy
- Find Center of Star GraphGraphEasy
- Destination CityGraphEasy
- Breadth-First Search (BFS) Traversal OrderGraphEasy
- Depth-First Search (DFS) Traversal OrderGraphEasy
- Count Connected Components in an Undirected GraphGraphEasy
- Size of the Component Containing a Given VertexGraphEasy
- Shortest Path in Unweighted Graph (BFS Hop Distance)GraphEasy
- Graph Valid Tree CheckGraphEasy
- Detect Cycle in an Undirected GraphGraphEasy
- Find the Unique Vertex with In-Degree ZeroGraphEasy
- Minimum Number of Vertices to Reach All NodesGraphEasy
- Flood Fill (Grid Graph)GraphEasy
- Island PerimeterGraphEasy
- Verify Valid Topological Sort OrderGraphEasy
- Maximum Degree of a Node in Connected ComponentGraphEasy
- BFS Level Order of VerticesGraphEasy
- Check if an Edge is a Bridge (Cut-Edge)GraphEasy
- Check if a Vertex is an Articulation Point (Cut-Vertex)GraphEasy
- Eccentricity of a Vertex in an Unweighted Connected GraphGraphEasy
- Check if Directed Graph is Weakly ConnectedGraphEasy
- Count Nodes Reachable from Source in Directed GraphGraphEasy
- Check if All Nodes Can Reach a Target VertexGraphEasy
- Count Triangles in an Undirected GraphGraphEasy
- Reconstruct Shortest Path Sequence (BFS Path)GraphEasy
- Check if Undirected Graph Has an Eulerian Circuit PreconditionGraphEasy
- Check Graph Isomorphism on 3-Vertex GraphsGraphEasy
- Check if an Undirected Graph is a Path GraphGraphEasy
- Check if an Undirected Graph is a Cycle GraphGraphEasy
- Vertices at Distance K in a TreeGraphEasy
- Course Schedule (Cycle Detection in Directed Graph)GraphMedium
- Course Schedule II (Topological Sort)GraphMedium
- Shortest Paths with Binary Edge Weights (0–1 BFS)GraphMedium
- Redundant Connection in Undirected GraphGraphMedium
- Evaluate DivisionGraphMedium
- Find Eventual Safe StatesGraphMedium
- Network Delay Time (Dijkstra's Shortest Path)GraphMedium
- Cheapest Flights Within K StopsGraphMedium
- Path with Minimum EffortGraphMedium
- Pacific Atlantic Water FlowGraphMedium
- Rotting OrangesGraphMedium
- 01 Matrix (Distance to Nearest Zero)GraphMedium
- Shortest BridgeGraphMedium
- Surrounded RegionsGraphMedium
- Accounts MergeGraphMedium
- Number of Operations to Make Network ConnectedGraphMedium
- Min Cost to Connect All Points (Minimum Spanning Tree)GraphMedium
- Possible Bipartition (Graph 2-Coloring with Dislikes)GraphMedium
- Shortest Path with Alternating ColorsGraphMedium
- Open the Lock (State-Space Graph BFS)GraphMedium
- As Far from Land as PossibleGraphMedium
- Shortest Path in Binary MatrixGraphMedium
- Number of Strongly Connected Components (Kosaraju's Algorithm)GraphMedium
- Parallel Courses (Kahn's Topological Sort with Semesters)GraphMedium
- Minimum Fuel Cost to Report to the CapitalGraphMedium
- Find the City With the Smallest Number of Neighbors at a Threshold DistanceGraphMedium
- Minimum Genetic Mutation (Gene Graph BFS)GraphMedium
- Keys and RoomsGraphMedium
- Is Graph Bipartite (2-Colorable)GraphMedium
- Number of IslandsGraphMedium
- Max Area of IslandGraphMedium
- Reorder Routes to Make All Paths Lead to City ZeroGraphMedium
- All Paths From Source to Target in a DAGGraphMedium
- Number of ProvincesGraphMedium
- Diameter of an Unweighted Tree GraphGraphMedium
- Radius of an Unweighted Tree GraphGraphMedium
- Find Center of an Unweighted TreeGraphMedium
- Shortest Paths with Negative Edges (Bellman–Ford)GraphMedium
- Smallest Subgraph Containing All Marked NodesGraphMedium
- Transitive Closure Matrix of a Directed GraphGraphMedium
- Check if Graph is a Complete Bipartite GraphGraphMedium
- Check if Directed Graph is Strongly ConnectedGraphMedium
- Count Crossing Edges After ContractionsGraphMedium
- All-Pairs Shortest Distances (Floyd–Warshall)GraphMedium
- Longest Distances and Path Counts in a DAGGraphMedium
- Minimum Spanning Tree Weight in a Weighted GraphGraphMedium
- Redundant Connection IIGraphHard
- Shortest Path Visiting All NodesGraphHard
- Word Ladder IIGraphHard
- Bus RoutesGraphHard
- Swim in Rising WaterGraphHard
- Maximum Employees to Be Invited to a Meeting (Functional Graph)GraphHard
- Find Critical and Pseudo-Critical Edges in Minimum Spanning TreeGraphHard
- Reachable Nodes in Subdivided GraphGraphHard
- Minimum Number of Days to Disconnect IslandGraphHard
- Trapping Rain Water II (2D Elevation Grid)GraphHard
- Cut Off Trees for Golf EventGraphHard
- Count Visited Nodes in a Directed GraphGraphHard
- Maximum Number of Non-Overlapping Substrings (Character Dependencies)GraphHard
- Minimum Cost to Reach Destination in TimeGraphHard
- Maximum Bipartite Matching (Augmenting Paths)GraphHard
- Valid Arrangement of Pairs (Eulerian Path)GraphHard
- Satisfiability of 2-SAT (Implication Graph)GraphHard
- Number of Increasing Paths in a GridGraphHard
- Sort Items by Groups Respecting DependenciesGraphHard
- Escape a Large MazeGraphHard
- Word Ladder (Shortest Transformation Sequence)GraphHard
- Reconstruct Itinerary (Hierholzer's Algorithm)GraphHard
- Critical Connections in a Network (Tarjan's Bridge Algorithm)GraphHard
- Find All Articulation Points in an Undirected Connected GraphGraphHard
- Alien Dictionary (Topological Sort)GraphHard
- Frog Position After T SecondsGraphHard
- Dinic's Maximum Flow Algorithm on Directed NetworkGraphHard
- Global Minimum Cut via Stoer-Wagner AlgorithmGraphVery hard
- Edmonds' Blossom Algorithm for General Maximum MatchingGraphVery hard
- Dominator Tree of a Flow Graph (Lengauer-Tarjan Algorithm)GraphVery hard
- Minimum Cost Maximum FlowGraphVery hard
- Planarity Testing of a Simple GraphGraphVery hard
- Dynamic Graph Connectivity via Offline DSU with RollbackGraphVery hard
- Directed Chinese Postman Problem (Min-Cost Eulerian Tour)GraphVery hard
- Tutte Matrix and Random Perfect Matching VerificationGraphVery hard