- Design and Analysis of Algorithms
- Home

- Basics of Algorithms
- DAA - Introduction
- DAA - Analysis of Algorithms
- DAA - Methodology of Analysis
- Asymptotic Notations & Apriori Analysis
- DAA - Space Complexities

- Design Strategies
- DAA - Divide & Conquer
- DAA - Max-Min Problem
- DAA - Merge Sort
- DAA - Binary Search
- Strassen’s Matrix Multiplication
- DAA - Greedy Method
- DAA - Fractional Knapsack
- DAA - Job Sequencing with Deadline
- DAA - Optimal Merge Pattern
- DAA - Dynamic Programming
- DAA - 0-1 Knapsack
- Longest Common Subsequence

- Graph Theory
- DAA - Spanning Tree
- DAA - Shortest Paths
- DAA - Multistage Graph
- Travelling Salesman Problem
- Optimal Cost Binary Search Trees

- Heap Algorithms
- DAA - Binary Heap
- DAA - Insert Method
- DAA - Heapify Method
- DAA - Extract Method

- Sorting Methods
- DAA - Bubble Sort
- DAA - Insertion Sort
- DAA - Selection Sort
- DAA - Quick Sort
- DAA - Radix Sort

- Complexity Theory
- Deterministic vs. Nondeterministic Computations
- DAA - Max Cliques
- DAA - Vertex Cover
- DAA - P and NP Class
- DAA - Cook’s Theorem
- NP Hard & NP-Complete Classes
- DAA - Hill Climbing Algorithm

- DAA Useful Resources
- DAA - Quick Guide
- DAA - Useful Resources
- DAA - Discussion

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Design and Analysis Multistage Graph

A multistage graph **G = (V, E)** is a directed graph where vertices are partitioned into **k** (where ** k > 1**) number of disjoint subsets

**such that edge**

*S = {s*_{1},s_{2},…,s_{k}}*(u, v)*is in E, then

*u Є s*and

_{i}*v Є s*for some subsets in the partition and |

_{1 + 1}**| = |**

*s*_{1}**| = 1.**

*s*_{k}The vertex ** s Є s_{1}** is called the

**source**and the vertex

**is called**

*t Є s*_{k}**sink**.

** G** is usually assumed to be a weighted graph. In this graph, cost of an edge

*(i, j)*is represented by

*c(i, j)*. Hence, the cost of path from source

**to sink**

*s***is the sum of costs of each edges in this path.**

*t*The multistage graph problem is finding the path with minimum cost from source ** s** to sink

**.**

*t*## Example

Consider the following example to understand the concept of multistage graph.

According to the formula, we have to calculate the cost **(i, j)** using the following steps

### Step-1: Cost (K-2, j)

In this step, three nodes (node 4, 5. 6) are selected as **j**. Hence, we have three options to choose the minimum cost at this step.

*Cost(3, 4) = min {c(4, 7) + Cost(7, 9),c(4, 8) + Cost(8, 9)} = 7*

*Cost(3, 5) = min {c(5, 7) + Cost(7, 9),c(5, 8) + Cost(8, 9)} = 5*

*Cost(3, 6) = min {c(6, 7) + Cost(7, 9),c(6, 8) + Cost(8, 9)} = 5*

### Step-2: Cost (K-3, j)

Two nodes are selected as j because at stage k - 3 = 2 there are two nodes, 2 and 3. So, the value i = 2 and j = 2 and 3.

*Cost(2, 2) = min {c(2, 4) + Cost(4, 8) + Cost(8, 9),c(2, 6) +*

* Cost(6, 8) + Cost(8, 9)} = 8*

*Cost(2, 3) = {c(3, 4) + Cost(4, 8) + Cost(8, 9), c(3, 5) + Cost(5, 8)+ Cost(8, 9), c(3, 6) + Cost(6, 8) + Cost(8, 9)} = 10*

### Step-3: Cost (K-4, j)

*Cost (1, 1) = {c(1, 2) + Cost(2, 6) + Cost(6, 8) + Cost(8, 9), c(1, 3) + Cost(3, 5) + Cost(5, 8) + Cost(8, 9))} = 12*

*c(1, 3) + Cost(3, 6) + Cost(6, 8 + Cost(8, 9))} = 13*

Hence, the path having the minimum cost is **1→ 3→ 5→ 8→ 9**.