0% found this document useful (0 votes)
5 views3 pages

Presentation On Distance Algorithm and Edge Coloring in Graph Theory

Uploaded by

moinbalouch1100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Presentation On Distance Algorithm and Edge Coloring in Graph Theory

Uploaded by

moinbalouch1100
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Presentation on Distance Algorithm

and
Edge Coloring in Graph Theory.
1. Introduction to Graph Theory

Graph: A set of vertices (nodes) connected by edges.


Applications: Networks, navigation, scheduling, etc.
Distance Algorithm: Finding shortest/longest paths.
Edge Coloring: Assigning colors to edges such that no two adjacent edges share the
same color.

2. Distance Algorithm

Definition: A method to calculate the shortest or longest path between nodes in a


graph.

Key Algorithms:

1. Dijkstra's Algorithm

Purpose: Finds the shortest path from a single source to all nodes.

Steps:

1. Initialize distances to ∞ and the source to 0.


2. Use a priority queue to extract the node with the smallest distance.
3. Update distances to adjacent nodes if a shorter path is found.
4. Repeat until all nodes are processed.
Time Complexity: O(V+E.logV)

2. Bellman-Ford Algorithm

Purpose: Handles graphs with negative weight edges.

Steps:
1. Initialize distances similar to Dijkstra.
2. Relax all edges V-1 times.
3. Check for negative-weight cycles.
Time Complexity: O(V.E).

3. Floyd-Warshall Algorithm

Purpose: Computes shortest paths between all pairs of nodes.

Steps:
1. Initialize a distance matrix.
2. Iteratively update distances using -Kth intermediate vertex.
Time Complexity: O(V3).
Applications: Navigation, network routing, project planning.
3. Edge Coloring
Definition: Assign colors to edges such that no two edges sharing the same vertex
have the same color.

Key Concepts:
1. Chromatic Index (x'(G)):
• Minimum number of colors required.
• For simple graphs:
►A(G) ≤ x'(G) ≤ A(G) +1
where (G) is the maximum degree of any vertex.

2. Vizing's Theorem:
• Classifies graphs into two types: Class 1 (x'(G) = A(G)) and Class 2 (x'(G) = ∆(G) +
1).

Algorithm for Edge Coloring:


1. Assign colors greedily.
2. Adjust if conflicts arise (e.g., using swapping techniques).
Applications: Scheduling, bandwidth allocation, resource management.

4. Practical Implementation

Distance Algorithm: Example in Java (Dijkstra's Algorithm):

import java.util.*;

class Graph {
private Map<Integer, List<int[]>> adj = new HashMap<>();

public void addEdge(int u, int v, int weight) {


adj.computeIfAbsent(u, k -> new ArrayList<>()).add(new int[]{v, weight});
}

public Map<Integer, Integer> dijkstra(int source) {


Map<Integer, Integer> dist = new HashMap<>();
PriorityQueue<int[]> pq = new PriorityQueue<>(Comparator.comparingInt(a ->
a[1]));
pq.add(new int[]{source, 0});
dist.put(source, 0);

while (!pq.isEmpty()) {
int[] current = pq.poll();
int u = current[0];
int d = current[1];

if (d > dist.getOrDefault(u, Integer.MAX_VALUE)) continue;

for (int[] neighbor : adj.getOrDefault(u, new ArrayList<>())) {


int v = neighbor[0], weight = neighbor[1];
int newDist = d + weight;

if (newDist < dist.getOrDefault(v, Integer.MAX_VALUE)) {


dist.put(v, newDist);
pq.add(new int[]{v, newDist});
}
}
}
return dist;
}
}

Edge Coloring: Example Approach (Greedy):

1. Create a list of edges.


2. Assign the smallest available color to each edge.

5. Conclusion

Distance Algorithms: Enable efficient pathfinding in graphs, critical for many real-
world applications.
Edge Coloring: Provides solutions for scheduling and resource allocation problems.
Both topics highlight the power of graph theory in computational problem-solving.

End of Presentation

You might also like