A Unified Approach to Path Problems - PowerPoint PPT Presentation

Loading...

PPT – A Unified Approach to Path Problems PowerPoint presentation | free to download - id: 723657-Yzg2N



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

A Unified Approach to Path Problems

Description:

Tarjan shows ... Solve SSPE. Use solution for other path problems. Natural homomorphism between R.E.s for path sets and algebras for given problems – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 44
Provided by: edua141
Learn more at: http://sydney.edu.au
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: A Unified Approach to Path Problems


1
A Unified Approach to Path Problems
  • Vasvi Kakkad
  • School of Information Technologies,
  • University of Sydney

2
Outline
  • Introduction
  • Path Problems
  • Shortest Path
  • System of Linear Equations
  • Data Flow Analysis
  • Constructing Regular Expressions from DFA
  • Summary

3
Introduction
  • Fundamental problem in Numerical Analysis
  • Ax b
  • Gaussian Gaussian Jordan Elimination Method
  • Floyds shortest path
  • Problem Find a faster, constructive finite
    solutions for non-constructive problems

4
Introduction
  • Solution Tarjan provided
  • Unified setting with algebra of Regular
    Expressions
  • Two steps method
  • Collection of Regular Expressions
  • Natural mapping from regular expression into
    problem domain

5
Definitions and Notations
  • S Finite Alphabet disjoint from ?, Ø, (,)
  • ? Empty string
  • Ø Empty set
  • Regular expression (R.E.)
  • ? and Ø are atomic R.E.
  • Any a in S, a is an atomic R.E.
  • If R1 and R2 are R.E., then (R1 U R2), (R1 R2)
    and (R1) are R.E.

6
Definitions and Notations
  • s(R) set of strings in R.E. R over S
  • s(a) a
  • s(?) ?
  • s(Ø) Ø
  • s(R1 U R2) w w in s(R1) or s(R2)
  • s(R1 R2) w1 w2 w1 in R1 and w2 in R2
  • s(R) wi w in R, i 0
  • Unambiguous R -
  • Each string in s(R) is represented uniquely

7
Definitions and Notations
  • Path expression (P.E.) -
  • P of type (s,v) is simple R.E. over E s.t. Every
    string in s(P) is path from s to v.
  • Single Source Path Expression Problem-
  • Path(s,v) s(REs-gtv )
  • Every sub expression of P is P.E.

s
v
8
Tarjan shows ...
  • Solve SSPE
  • Use solution for other path problems
  • Natural homomorphism between R.E.s for path sets
    and algebras for given problems
  • Reinterpret U, and operations to construct
    regular expressions.
  • Fast Algorithm O(ma(m,n))

9
3 Problems
  • Shortest Path Problem
  • System of Linear Equations
  • Global Data Flow Analysis

10
Shortest Paths
11
Example
  • Dijkstras Shortest Path
  • For each node,
  • Find next node with least cost
  • Cost of edge e c(e)
  • Cost of path from e1 to ek c(e1) c(e2)
    ...c(ek)
  • Shortest path - Si1..k c(ei) is minimum

12
Step 1 Collect Path Expressions
  • Path expressions from start node 1 to end node 5
  • P1 (1,6) (6,5)
  • P2 (1,3) (3,6) (6,5)
  • P3 (1,3) (3,4) (4,5)
  • P4 (1,2) (2,3) (3,6) (6,5)
  • P5 (1,2) (2,3) (3,4) (4,5)
  • P6 (1,2) (2,4) (2,5)
  • P(1,5) P1 U P2 U P3 U P4 U P5 U P6

13
Step 2 Mappings
  • cost(?) 0 shortest path(?) ?
  • cost(Ø) 8 shortest path(Ø) no path
  • cost(e) c(e) shortest path(e) e
  • cost(P1 U P2) mincost(P1), cost(P2)
  • shortest path(P1 U P2) if cost(P1) cost(P2)
    then shortest path(P1) else shortest path(P2)
  • cost(P1 P2) cost(P1) cost(P2)
  • shortest path(P1 P2) shortest path(P1)
    shortest path(P2)
  • cost(P1) 0
  • shortest path(P1)?

14
Solve Path Expression
  • Compute shortest path
  • P1 (1,6)(6,5) ? cost(P1) 149 25
  • P2 (1,3)(3,6)(6,5) ? cost(P2) 929 20
  • P3 (1,3)(3,4)(4,5) ? cost(P3) 9116 26
  • P4 (1,2)(2,3)(3,6)(6,5)?cost(P4)71129
    29
  • P5 (1,2)(2,3)(3,4)(4,5)?cost(P5)710116
    34
  • P6 (1,2)(2,4)(2,5)?cost(P6) 7156 28
  • P(1,5) P1 U P2 U P3 U P4 U P5 U P6 ?
    min(cost(P1), cost(P2),...,cost(P6)) 20 ? P2

15
Prove Homomorphism
  • Theorem
  • Let P(v, w) be a path expression representing
    all paths from v to w.
  • - If cost(P(v, w)) 8, no path from v to w.
  • - Otherwise, shortest path(P(v, w)) is a
    shortest path from v to w, and its cost is
    cost(P(v, w))

16
Prove Homomorphism
  • Theorem
  • Let P1(v, w) be a path expression such that
    s(P1(v, w)) contains at least all the simple
    paths from v to w.
  • - If there is a shortest path from v to w,
    shortest path(P1(v,w)) gives one such path, and
    its cost is cost(P1(v, w)).

17
Systems of Linear Equations
18
Problem
  • Find solution for Ax b over set of real numbers
  • No solution
  • Need not be unique solution
  • Gaussian elimination may not succeed
  • Proposed method either gives solution or divides
    by zero

19
Regular expressions- Mapping
  • Rewrite Ax b as b (I-A)x x
  • Where

20
Example
  • Solve
  • 2x1 x2 10 .... (1)
  • x1 5x2 23 .... (2)
  • 1
  • 1 5

x1 x2
10 23
A
x
b
1 0 0
0 0 0 10 -1 -1 23 -1 -4
x0 x1 x2
x0 x1 x2
A
21
Example
x0 x1 x2
0 0 0 10 -1 -1 23 -1 -4
x0 x1 x2
  • x0 1
  • x1 10x0 x1 x2
  • x2 23x0 x1 - 4x2
  • x(s) 1
  • Solve x(v) Sa(e) x(h(e))

A
x0
10
23
-1
x1
x2
-1
-1
-4
22
Step 1 Collect Regular Expression
  • P(x0,x1) (x0,x1) (x1,x1) ( x1,x2)
    (x,x2) (x2,x1) U (x0,x2) (x2,x2)
    (x2,x1) (x1,x1) ( x1,x2) (x2,x2)
    (x2,x1)
  • P(x0,x2) (x0,x2) (x2,x2) (x2,x1)
    (x1,x1) (x1,x2) U (x0,x1) (x1,x1)
    (x1,x2) (x2,x2) (x2,x1) (x1,x1)
    (x1,x2)

x0
10
23
-1
x1
x2
-1
-1
-4
23
Step 2 Mapping
  • Map a to regular expressions over E
  • a(?) 1
  • a(Ø) 0
  • a(R) a(e)
  • a(R1 U R2) a(R1) a(R2)
  • a(R1 R2) a(R1) a(R2)
  • a(R1) 1/(1 a(R1)) if a(R1) ? 1

24
Solve Regular Expression
  • P(x0,x1) (x0,x1) (x1,x1) ( x1,x2)
    (x,x2) (x2,x1) U
  • (x0,x2) (x2,x2) (x2,x1) (x1,x1) (
    x1,x2) (x2,x2) (x2,x1)
  • P(x0,x1) 10 1/(1-(-1)) 1/1-(-1)
    1/1-(-4) (-1)
  • 23 1/(1-(-4)) (-1) 1/(1-(-1)) 1/1-(-1)
    1/1-(-4) (-1)
  • P(x0,x1) 27/8
  • P(x0,x2) 13/4

25
Prove Homomorphism
  • Lemma
  • If R is any unambiguous R.E. over E, there are
    polynomials p and q in variables a(e1), a(e2)...,
    a(em) such that, a(R) p/q if both sides are
    defined. q ? 0
  • Constant term in q is 1, and
  • Constant term in p is 0 if ? is not in s(R), 1
    if ? is in s(R).
  • Proof by Induction on number of operation
    symbols

26
Prove Homomorphism
  • Theorem
  • For each vertex v, let P(s, v) be an
    unambiguous P.E. representing all paths from s to
    v.
  • If a(P(s,v)) is defined for all v, then the
    mapping x defined by x(v) a(P(s, v)) satisfies
    following equation
  • x(v) Sa(e) x(h(e)) e in E and t(e) v
  • x(v) a(P(s,v)) a(UP(s, h(e))e e in E and
    t(e) v)
  • S a(e)x(h(e)) e in E and t(e) v

27
Constructing Regular Expressions from DFA
  • Hopcroft, Ullman Elimination method

28
DFA
  • Deterministic finite automata
  • Set of states
  • Set of input symbols
  • Set of transfer functions
  • Start state
  • Set of accepting/final states

29
From DFA to regular expression
  • L L(A) then L L(R)
  • R(k)ij regular expression for path from i to j in
    A
  • Intermediate states lt k

30
Basis
  • If k0 then
  • An arc from i to j
  • Path of length 0 of only one node i
  • If i ? j then, find input symbol a that is
    transition from i to j
  • If no such a then Rij(0) ?
  • If exactly one such a, then Rij(0) a
  • If a1, a2, , ak then Rij(0) a1 a2 ak
  • If i j then, add ?

31
Induction
  • If path does not go through k then label of path
  • Rij(k-1)
  • If path goes through k at least once then
  • Break the path into several pieces
  • Rij(k) Rij(k-1) Rik(k-1) (Rkk(k-1) )
    Rkj(k-1)

i
k
k
k
k
j
Rkk(k-1)
Rik(k-1)
Rkj(k-1)
32
Example
0,1
1
0
1
2

R11(0) ? 1
R12(0) 0
R21(0) ?
R22(0) (? 0 1)
33
Example
  • Rij(1) Rij(0) Ri1(0) (R11(0) ) R1j(0)


R11(1) ? 1 (? 1)(? 1)(? 1) 1
R12(1) 0 (? 1) (? 1)0 10
R21(1) Ø Ø (? 1) (? 1) Ø
R22(1) (? 0 1) Ø (? 1)0 ? 0 1
34
Elimination method
R1m
p1
R11
q1
S
Q1
P1
s
Pm
Qk
Rkm
qk
pm
Rk1
35
Step 1- Intermediate State
R11 Q1 S P1
p1
q1
R1m Q1 S Pm
Rk1 Qk S P1
qk
pm
Rkm Qk S Pm
36
Step 2 Two States Automaton
U
R
S
1
2
T
(R SUT) SU
37
Steps 3 4
  • Start state is an accepting state
  • Eliminate all states but start state
  • If more than one accepting state
  • Sum of all the regular expressions for each
    accepting state

38
Example
0,1
0,1
0,1
A
B
C
D
1
01
01
01
A
B
C
D
1
39
Example
01
01
1 (01)
A
C
D
Eliminating State B
40
Example
01
1 (01) (01)
A
D
Eliminating State C
01
1 (01)
A
C
Eliminating State D
41
Example
  • Final regular expression for
  • (01) 1(01) (01) 1(01) (01)

0,1
0,1
0,1
A
B
C
D
1
42
Final words
  • Solving path problems
  • Tarjan showed unified settings
  • Homomorphism between regular expressions and
    actual problem algebra
  • Solution to SSPE problem can be used to solve all
    path related problems
  • Converting DFA into regular expression
  • Elimination method

43
Thank You...
About PowerShow.com