Introduction to Graph Basics
Graph theory is a fundamental area of discrete mathematics with extensive applications in computer science. Graphs are used to model networks, relationships, and structures in various domains such as social networks, communication systems, data organization, and more. Understanding graph theory is essential for algorithm design, data structures, network analysis, and solving complex computational problems.
In this lecture, we will explore the foundational concepts of graph theory, progressing through a structured sequence to build a comprehensive understanding:
- Definition of a Graph
- Edges and Their Properties
- Types of Graphs
- Degree of a Vertex
- Degree Sum Formula
- Graph Representations
- Graph Data Structures in Practice
- Paths and Walks
- Result: Any Walk Contains a Path
- Connectedness and Connected Components
- Trees
- Properties of Trees
- Circuits and Cycles
- Graph Algorithms Applications
A graph \( G \) is a mathematical structure used to model pairwise relations between objects. It consists of two finite sets:
- A set of vertices (also called nodes), denoted by \( V \).
- A set of edges, denoted by \( E \), which are pairs of vertices.
The graph is denoted as:
\[ G = (V, E) \]
- Can a graph have no edges?
- Yes. Such a graph is called an edgeless graph or an empty graph. It consists solely of isolated vertices.
- Can there be multiple edges between the same pair of vertices?
- Yes, in a multigraph. In a simple graph, there is at most one edge between any pair of vertices.
Let \( V = {A, B, C, D} \) and \( E = {(A, B), (B, C), (C, D)} \).
Visualization:
A --- B --- C --- D
Explanation: Each vertex represents an object, and each edge represents a relationship between two objects.
Let \( V = {1, 2, 3} \) and \( E = \emptyset \).
Visualization:
1 2 3
Explanation: No edges connect the vertices; the graph consists of isolated points.
Vertices represent servers in a network \( V = {S1, S2, S3} \), and edges represent direct communication links \( E = {(S1, S2), (S2, S3)} \).
Visualization:
S1 --- S2 --- S3
Explanation: Models a network where servers are connected if they can communicate directly.
- Endpoints of an Edge: The two vertices connected by an edge.
- Incident Edges: Edges that are connected to a vertex.
- Adjacency: Two vertices are adjacent if they are connected by an edge.
- Is an edge from a vertex to itself valid?
- Yes. It’s called a loop or self-loop.
- Can an edge exist without connecting any vertices?
- No. By definition, an edge must connect two vertices (which may be the same in the case of a loop).
Given graph \( G = (V, E) \) with \( V = {A, B, C} \) and \( E = {(A, B), (A, C)} \).
- Incident Edges on Vertex A: \( (A, B) \), \( (A, C) \).
- Explanation: Vertex A has two edges connected to it.
In the same graph, vertices B and C are not adjacent because there is no edge between them.
- Adjacency List:
- A: B, C
- B: A
- C: A
In a social network, users are vertices \( V = {\text{Alice}, \text{Bob}, \text{Carol}} \), and friendships are edges \( E = {(\text{Alice}, \text{Bob}), (\text{Bob}, \text{Carol})} \).
- Adjacency:
- Alice and Bob are adjacent.
- Bob and Carol are adjacent.
- Alice and Carol are not adjacent.
- Directed Graphs: Edges have a direction, represented as ordered pairs \( (u, v) \).
- Undirected Graphs: Edges have no direction, represented as unordered pairs \( {u, v} \).
- Loops (Self-Loops): Edges that connect a vertex to itself.
- In a directed graph, is the edge \( (u, v) \) the same as \( (v, u) \)?
- No. The edge \( (u, v) \) goes from \( u \) to \( v \); direction matters.
- Can a graph be both directed and undirected?
- Yes. Such graphs are called mixed graphs, containing both directed and undirected edges.
Let \( V = {1, 2, 3} \) and \( E = {(1, 2), (2, 3)} \).
Visualization:
1 --> 2 --> 3
Explanation: Represents processes or dependencies where direction is significant.
Let \( V = {A, B} \) and \( E = {(A, A), (A, B)} \).
Visualization:
(Loop at A) A --- B
Explanation: Vertex A has a self-loop and is connected to B.
Vertices represent web pages, edges represent hyperlinks.
Directed Graph: If page A links to page B, there is an edge \( (A, B) \).
Example:
- \( V = {\text{Home}, \text{About}, \text{Contact}} \)
- \( E = {(\text{Home}, \text{About}), (\text{About}, \text{Contact}), (\text{Contact}, \text{Home})} \)
Visualization:
Home --> About --> Contact --> Home
- Degree in Undirected Graphs: Number of edges incident to a vertex.
- In-Degree in Directed Graphs: Number of edges coming into a vertex.
- Out-Degree in Directed Graphs: Number of edges going out from a vertex.
- Counting Self-Loops:
- In undirected graphs, a loop adds 2 to the degree.
- In directed graphs, a loop adds 1 to both in-degree and out-degree.
- How is a self-loop counted in degree?
- Undirected Graph: Adds 2 to the degree.
- Directed Graph: Adds 1 to both in-degree and out-degree.
- Can a vertex have zero degree?
- Yes. Such a vertex is called an isolated vertex.
Graph with \( V = {A, B, C} \) and \( E = {(A, B), (A, C), (B, C)} \).
- Degrees:
- \( \deg(A) = 2 \)
- \( \deg(B) = 2 \)
- \( \deg(C) = 2 \)
Graph with \( V = {X} \) and \( E = {(X, X)} \).
- Degree of X:
- Undirected: \( \deg(X) = 2 \)
- Directed:
- In-degree: 1
- Out-degree: 1
Vertices represent servers; directed edges represent data packets sent.
- Graph:
- \( V = {S1, S2, S3} \)
- \( E = {(S1, S2), (S2, S3), (S2, S1)} \)
- Degrees:
- S1:
- In-degree: 1 (from S2)
- Out-degree: 1 (to S2)
- S2:
- In-degree: 1 (from S1)
- Out-degree: 2 (to S1 and S3)
- S3:
- In-degree: 1 (from S2)
- Out-degree: 0
- S1:
- Degree Sum Formula:
- For undirected graphs: \( \sum_{v \in V} \deg(v) = 2e \), where \( e \) is the number of edges.
- For directed graphs:
- Sum of in-degrees: \( \sum_{v \in V} \deg_{in}(v) = e \)
- Sum of out-degrees: \( \sum_{v \in V} \deg_{out}(v) = e \)
- Does the formula hold for graphs with self-loops?
- Yes. Self-loops contribute correctly when degrees and edges are counted properly.
- How does the formula adapt to directed graphs?
- The sum of all in-degrees equals the sum of all out-degrees, both equal to the number of edges.
Graph with \( V = {A, B, C} \) and \( E = {(A, B), (B, C)} \).
- Degrees:
- \( \deg(A) = 1 \)
- \( \deg(B) = 2 \)
- \( \deg(C) = 1 \)
- Degree Sum: \( 1 + 2 + 1 = 4 \)
- Edges: \( e = 2 \)
- Verification: \( 2e = 4 \)
Graph with \( V = {1, 2, 3} \) and \( E = {(1, 2), (2, 3), (3, 1)} \).
- In-Degrees:
- \( \deg_{in}(1) = 1 \)
- \( \deg_{in}(2) = 1 \)
- \( \deg_{in}(3) = 1 \)
- Out-Degrees:
- \( \deg_{out}(1) = 1 \)
- \( \deg_{out}(2) = 1 \)
- \( \deg_{out}(3) = 1 \)
- Sum of In-Degrees: \( 1 + 1 + 1 = 3 \)
- Sum of Out-Degrees: \( 1 + 1 + 1 = 3 \)
- Edges: \( e = 3 \)
- Verification: Sum of degrees equals number of edges.
Vertices represent web pages, edges represent hyperlinks.
- Graph:
- \( V = {\text{Home}, \text{Products}, \text{Contact}} \)
- \( E = {(\text{Home}, \text{Products}), (\text{Products}, \text{Contact}), (\text{Contact}, \text{Home})} \)
- Degrees:
- In-Degrees:
- Home: 1
- Products: 1
- Contact: 1
- Out-Degrees:
- Home: 1
- Products: 1
- Contact: 1
- In-Degrees:
- Verification: Sum of in-degrees and out-degrees both equal the number of edges (3).
- Adjacency Lists: Each vertex stores a list of adjacent vertices.
- Efficient for sparse graphs (graphs with relatively few edges).
- Adjacency Matrices: A 2D array where entry \( [i][j] \) indicates the presence of an edge from vertex \( i \) to vertex \( j \).
- Efficient for dense graphs (graphs with many edges).
- How are self-loops represented?
- In adjacency matrices, self-loops are entries where row and column indices are the same.
- What if the graph is very large?
- Adjacency lists are preferred due to space efficiency.
Graph with \( V = {1, 2, 3} \) and \( E = {(1, 2), (2, 3)} \).
- Adjacency List:
- 1: 2
- 2: 1, 3
- 3: 2
Same graph represented as an adjacency matrix:
\[ \begin{array}{c|ccc} & 1 & 2 & 3 \ \hline 1 & 0 & 1 & 0 \ 2 & 1 & 0 & 1 \ 3 & 0 & 1 & 0 \ \end{array} \]
- Explanation: Entry at \( [i][j] \) is 1 if there is an edge between \( i \) and \( j \).
Vertices represent airports, edges represent direct flights.
- Airports: \( V = {\text{JFK}, \text{LAX}, \text{ORD}, \text{DFW}} \)
- Edges: Direct flights between airports.
- Adjacency List:
- JFK: LAX, ORD
- LAX: JFK, DFW
- ORD: JFK, DFW
- DFW: LAX, ORD
- Adjacency Matrix:
\[ \begin{array}{c|cccc} & \text{JFK} & \text{LAX} & \text{ORD} & \text{DFW} \ \hline \text{JFK} & 0 & 1 & 1 & 0 \ \text{LAX} & 1 & 0 & 0 & 1 \ \text{ORD} & 1 & 0 & 0 & 1 \ \text{DFW} & 0 & 1 & 1 & 0 \ \end{array} \]
- Edge Lists: A list of all edges in the graph.
- Each edge is represented as a pair (or tuple) of vertices.
- Incidence Lists: For each vertex, a list of incident edges.
- Trade-offs:
- Space and time efficiency vary based on the graph representation and operations performed.
- How to represent parallel edges in edge lists?
- Include multiple entries for the same pair of vertices.
- Can incidence lists handle directed edges?
- Yes. By distinguishing between incoming and outgoing edges.
Graph with \( V = {A, B, C} \) and \( E = {(A, B), (B, C), (A, B)} \) (multigraph with parallel edges).
- Edge List:
- (A, B)
- (A, B)
- (B, C)
- Incidence List:
- A: Edges (A, B), (A, B)
- B: Edges (A, B), (A, B), (B, C)
- C: Edge (B, C)
Vertices represent cities, edges represent roads.
- Edge List:
- (City1, City2, Distance)
- (City2, City3, Distance)
- (City1, City2, Distance) (Parallel road with different distance or properties)
- Incidence List:
- City1: Edges to City2
- City2: Edges to City1, City3
- City3: Edge to City2
- Path: A sequence of vertices where each adjacent pair is connected by an edge, and no vertices are repeated.
- Walk: A sequence of vertices and edges where vertices and edges can repeat.
- Length of a Path: Number of edges in the path.
- Can a path have length zero?
- Yes. A path from a vertex to itself with no edges.
- Is every path a walk?
- Yes. But not every walk is a path.
Graph with \( V = {1, 2, 3, 4} \) and edges connecting sequential vertices.
- Path from 1 to 4: \( 1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \)
- Length: 3 edges.
- Walk: \( 1 \rightarrow 2 \rightarrow 3 \rightarrow 2 \rightarrow 3 \rightarrow 4 \)
- Vertices Repeated: 2 and 3.
- Not a Path: Because vertices are repeated.
- Vertices: Directories and files.
- Edges: Navigating from one directory to another.
- Path: A unique sequence of directories from root to a file without revisiting directories.
- Walk: Navigating directories where you might revisit parent directories.
- Simplifying a Walk to a Path: Removing cycles to create a path.
- Implications: Demonstrates that connectivity can be represented by paths.
- What if the walk is a closed loop?
- Simplifying the walk will result in a cycle or a path between different vertices.
- Does this apply to infinite graphs?
- Generally applied to finite walks in finite graphs.
Given a walk: \( A \rightarrow B \rightarrow C \rightarrow B \rightarrow D \)
- Repeated Vertex: B
- Simplify: Remove cycle between B and C.
- Resulting Path: \( A \rightarrow B \rightarrow D \)
Walk: \( A \rightarrow B \rightarrow C \rightarrow A \)
- Cycle: Starts and ends at A.
- Simplification: Cannot create a path without removing edges.
- Result: A cycle remains.
- Vertices: Functions in a program.
- Edges: Function calls.
- Walk: Sequence of function calls, possibly with recursion (repeated functions).
- Simplify: Remove recursive cycles to understand the sequence of unique function calls (path).
- Connected Graph: A graph where there is a path between every pair of vertices.
- Disconnected Graph: Not all vertices are connected.
- Connected Components: Maximal connected subgraphs.
- Isolated Vertices: Vertices with no edges.
- Can a single vertex be a connected component?
- Yes. If it has no edges connecting it to other vertices.
- Is an empty graph connected?
- No. Unless it has only one vertex.
Graph with vertices \( {1, 2, 3} \) and edges \( {(1, 2), (2, 3)} \).
- Observation: Paths exist between all pairs.
- Conclusion: Graph is connected.
Graph with vertices \( {A, B, C, D} \) and edges \( {(A, B)} \).
- Connected Components:
- Component 1: \( {A, B} \)
- Component 2: \( {C} \)
- Component 3: \( {D} \)
- Observation: No paths between components.
- Vertices: Computers in a network.
- Edges: Direct communication links.
- Scenario: Network split due to a failure.
- Connected Components: Subnetworks where computers can communicate internally but not with other subnets.
- Implication: Understanding connected components helps in network recovery.
- Tree: A connected graph with no cycles (acyclic).
- Properties: Minimal connectivity.
- Is a single vertex a tree?
- Yes. It’s called a trivial tree.
- Can a tree have cycles?
- No. By definition, a tree is acyclic.
Graph with \( V = {A, B, C} \) and edges \( {(A, B), (B, C)} \).
- Observation: Connected and acyclic.
- Conclusion: It’s a tree.
Graph with central vertex \( C \) connected to all other vertices.
- Vertices: \( V = {C, V1, V2, V3} \)
- Edges: \( {(C, V1), (C, V2), (C, V3)} \)
- Observation: No cycles.
- Conclusion: It’s a tree.
- Vertices: Folders and files.
- Edges: Parent-child relationships.
- Observation: Hierarchical, connected, and acyclic.
- Conclusion: File systems are modeled as trees.
- Leaf: A vertex of degree one in a tree.
- Edge and Vertex Relationship: In any tree, \( e = v - 1 \).
- Can a tree be disconnected?
- No. A tree is, by definition, connected.
- Is the center of a tree always a single vertex?
- Not necessarily. Some trees have two central vertices.
Tree with \( V = {1, 2, 3, 4} \) and edges \( {(1, 2), (2, 3), (2, 4)} \).
- Leaves: Vertices 1, 3, 4 (degree 1).
- Internal Vertex: Vertex 2 (degree 3).
- Vertices: \( v = 5 \)
- Edges: For a tree, \( e = v - 1 = 4 \)
- Example: Edges connect the vertices without forming cycles.
- Vertices: Positions in a company.
- Edges: Reporting lines.
- Observation: Forms a tree structure.
- Properties:
- Leaves represent employees with no subordinates.
- The root represents the CEO or top-level management.
- Circuit: A closed walk where the start and end vertices are the same.
- Cycle: A circuit with no repeated vertices or edges (except the start/end vertex).
- Is a self-loop a cycle?
- Yes, in some definitions. It can be considered a cycle of length one.
- Can a cycle be of length two?
- Yes, in graphs with parallel edges. In simple graphs, cycles must be of length at least three.
Graph with \( V = {A, B, C} \) and edges \( {(A, B), (B, C), (C, A)} \).
- Cycle: \( A \rightarrow B \rightarrow C \rightarrow A \)
- Length: 3 edges.
Walk: \( A \rightarrow B \rightarrow C \rightarrow B \rightarrow A \)
- Circuit: Starts and ends at A.
- Repeated Vertices: B appears twice.
- Not a Cycle: Because vertices are repeated (other than start/end).
- Vertices: Processes.
- Edges: Resource requests or holdings.
- Cycle Detection: A cycle in the graph indicates a potential deadlock.
- Application: Identifying cycles helps in resolving resource allocation issues.
- Social Network Analysis: Modeling relationships using graphs.
- Web Crawling and Search Engines: Representing the web as a graph of pages and links.
- Routing and Navigation Systems: Using graphs to model and optimize routes.
- How to represent asymmetric relationships?
- Use directed graphs where edges have direction.
- What if the network changes over time?
- Use dynamic graphs that update representations as changes occur.
- Vertices: Users.
- Edges: Friendships or follows.
- Applications:
- Finding communities.
- Suggesting friends.
- Vertices: Web pages.
- Edges: Hyperlinks.
- Applications:
- PageRank algorithm.
- Crawling strategies.
- Vertices: Intersections.
- Edges: Roads with distances or travel times.
- Applications:
- Shortest path algorithms (e.g., Dijkstra’s).
- Traffic optimization.
In this section, we present key properties and theorems in graph theory, accompanied by rigorous, step-by-step proofs using mathematical notation.
In any undirected graph \( G = (V, E) \), the sum of the degrees of all vertices equals twice the number of edges.
Mathematical Expression:
\[ \sum_{v \in V} \deg(v) = 2|E| \]
Objective: Prove that \(\sum_{v \in V} \deg(v) = 2|E|\).
Proof:
Consider an undirected graph \( G = (V, E) \).
Definition of Degree:
- For each vertex \( v \in V \), \(\deg(v)\) is the number of edges incident to \( v \).
- An edge \( e = {u, v} \in E \) contributes 1 to \(\deg(u)\) and 1 to \(\deg(v)\).
Counting Edge Contributions:
- Each edge \( e \in E \) connects two vertices.
- Therefore, each edge contributes exactly 2 to the total degree sum.
Summing over All Edges:
The total sum of degrees is:
\[ \sum_{v \in V} \deg(v) = \sum_{e = {u, v} \in E} [1 \text{ (for } u) + 1 \text{ (for } v)] = 2|E| \]
Conclusion:
The sum of the degrees of all vertices in an undirected graph is twice the number of edges:
\[ \sum_{v \in V} \deg(v) = 2|E| \]
In any graph \( G = (V, E) \), any walk from vertex \( u \) to vertex \( v \) contains a path from \( u \) to \( v \).
Objective: Given any walk \( W \) from \( u \) to \( v \), show that there exists a path \( P \) from \( u \) to \( v \) contained within \( W \).
Proof:
Definition of Walk:
A walk \( W \) is a sequence of vertices:
\[ W = (w_0, w_1, w_2, \dotsc, w_k) \]
where \( w_0 = u \), \( w_k = v \), and \( (w_i, w_{i+1}) \in E \) for all \( 0 \leq i < k \).
Constructing the Path:
- Initialize \( P \) as the sequence of vertices in \( W \).
Removing Cycles:
While \( P \) contains repeated vertices, do the following:
a. Find Repeated Vertex:
- Find indices \( i \) and \( j \) such that \( i < j \) and \( w_i = w_j \).
b. Remove the Cycle:
- Remove the subsequence \( (w_{i+1}, w_{i+2}, \dotsc, w_j) \) from \( P \).
- The new sequence \( P \) connects \( u \) to \( v \) and is shorter.
This process removes cycles (closed loops) from \( P \).
Resulting Path:
- After all cycles are removed, \( P \) is a sequence of vertices with no repetitions, i.e., a path.
Conclusion:
Any walk from \( u \) to \( v \) contains a path from \( u \) to \( v \).
Statement:
In any tree \( T = (V, E) \), the number of edges is one less than the number of vertices:
\[ |E| = |V| - 1 \]
Objective: Prove that \( |E| = |V| - 1 \) for any tree.
Proof by Induction on \( |V| \):
Base Case (\( |V| = 1 \)):
- A tree with one vertex has no edges.
- Therefore, \( |E| = 0 = 1 - 1 = |V| - 1 \).
- Base case holds.
Inductive Step:
Assume the theorem holds for all trees with \( n \) vertices (\( |E| = n - 1 \)).
Consider a tree \( T \) with \( n + 1 \) vertices.
Existence of a Leaf:
- In a tree, there must be at least one leaf (vertex of degree 1).
- Let \( v \) be a leaf in \( T \).
Forming a Smaller Tree:
- Remove \( v \) and its incident edge from \( T \), resulting in a smaller tree \( T’ \) with \( n \) vertices.
Applying Induction Hypothesis:
- By induction, \( |E’| = n - 1 \), where \( |E’| \) is the number of edges in \( T’ \).
Calculating \( |E| \):
- \( |E| = |E’| + 1 = (n - 1) + 1 = n \)
Verifying the Formula:
- \( |E| = n = (n + 1) - 1 = |V| - 1 \)
Conclusion:
By induction, the theorem holds for all trees.
Statement:
Every tree \( T = (V, E) \) with \( |V| \geq 2 \) has at least two vertices of degree 1 (leaves).
Objective: Prove that any tree with \( |V| \geq 2 \) has at least two leaves.
Proof:
Consider the Longest Path in \( T \):
- Let \( P \) be the longest path in \( T \), with endpoints \( u \) and \( v \).
Degrees of \( u \) and \( v \):
- Suppose, for contradiction, that \( \deg(u) \geq 2 \).
- Then there exists an edge \( (u, w) \) not in \( P \).
Contradiction:
- Adding \( (u, w) \) to \( P \) would create a longer path, contradicting the maximality of \( P \).
Conclusion:
- Therefore, \( \deg(u) = 1 \).
- Similarly, \( \deg(v) = 1 \).
- Thus, \( T \) has at least two leaves.
Conclusion:
Every tree with at least two vertices has at least two leaves.
A graph \( G = (V, E) \) is connected if for every pair of vertices \( u, v \in V \), there exists a path from \( u \) to \( v \).
Connected Components:
- A connected component is a maximal set of vertices \( C \subseteq V \) such that for every \( u, v \in C \), there exists a path from \( u \) to \( v \).
Isolated Vertices:
- A vertex \( v \) with \( \deg(v) = 0 \) is called an isolated vertex.
- Each isolated vertex forms its own connected component.
Implications:
- In a connected graph, there is exactly one connected component.
- Understanding connected components is crucial for analyzing graph connectivity.
Statement:
In any group of six people, there are either three mutual friends or three mutual strangers.
Objective: Prove the statement using graph theory.
Proof:
Modeling the Problem:
- Represent each person as a vertex.
- For every pair of people, draw an edge:
- Color it red if they are friends.
- Color it blue if they are strangers.
Applying the Pigeonhole Principle:
- Select any vertex \( v \).
- \( v \) has five edges connected to other vertices.
- By the Pigeonhole Principle, at least three edges must be the same color.
- Without loss of generality, assume \( v \) has at least three red edges to vertices \( v_1, v_2, v_3 \).
Analyzing Connections Among \( v_1, v_2, v_3 \):
- If any pair among \( v_1, v_2, v_3 \) is connected by a red edge, say \( (v_1, v_2) \), then \( v, v_1, v_2 \) form a triangle of mutual friends.
- If none of \( v_1, v_2, v_3 \) are connected by red edges, then all edges between them are blue, and \( v_1, v_2, v_3 \) form a triangle of mutual strangers.
Conclusion:
In any case, there exists a trio of mutual friends or mutual strangers.
Statement:
In a tree \( T = (V, E) \), removing any edge results in a disconnected graph.
Objective: Show that removing any edge \( e \in E \) from \( T \) disconnects \( T \).
Proof:
Properties of Trees:
- Trees are connected and acyclic.
Contradiction:
- Suppose removing edge \( e = (u, v) \) does not disconnect \( T \).
- Then there exists another path between \( u \) and \( v \) in \( T \setminus {e} \).
Cycle Formation:
- The existence of another path implies a cycle in \( T \), consisting of edge \( e \) and the alternative path between \( u \) and \( v \).
Contradiction:
- This contradicts the acyclic property of trees.
Conclusion:
Removing any edge from a tree disconnects it.
- Graphs are powerful tools for modeling relationships and structures.
- Understanding the foundational concepts, properties, and representations of graphs is essential for various applications in computer science.
- Edge cases highlight important considerations and exceptions that deepen comprehension.
- Examples illustrate concepts in practical and computational contexts.
- Degree Sum Verification:
- Given an undirected graph with 5 vertices and 7 edges, verify the degree sum formula.
- Graph Representation Conversion:
- Convert the given adjacency list to an adjacency matrix:
- Adjacency List:
- A: B, C
- B: A, D
- C: A, D
- D: B, C
- Adjacency List:
- Convert the given adjacency list to an adjacency matrix:
- Path and Walk Identification:
- In the following graph, list all possible paths from vertex 1 to vertex 4:
- Edges: (1,2), (2,3), (3,4), (1,3), (2,4)
- In the following graph, list all possible paths from vertex 1 to vertex 4:
- Tree Properties:
- Prove that a tree with 10 vertices has exactly 9 edges.
- Cycle Detection:
- Given a directed graph representing tasks with dependencies, determine if there is a cycle indicating a circular dependency.
- Edge cases help identify limitations and special conditions.
- Understanding edge cases prevents misconceptions and errors in applications.
- Data Structures: Trees, graphs, and their implementations.
- Algorithms: Graph traversal, shortest paths, network flows.
- Networking: Modeling and analyzing communication networks.
- Artificial Intelligence: Graph-based representations in problem-solving.