10.3%20??%20??%20(Topological%20Sort) - PowerPoint PPT Presentation

About This Presentation
Title:

10.3%20??%20??%20(Topological%20Sort)

Description:

Title: 5 Last modified by: Created Date: 5/16/1999 2:20:14 PM Document presentation format: Company: SNU DBLAB Other titles – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 25
Provided by: ackr
Category:

less

Transcript and Presenter's Notes

Title: 10.3%20??%20??%20(Topological%20Sort)


1
?? ?? (?? ??)
  • ?? ?? ?? (11 ? 16?)
  • 10.2 ?? ??
  • ?? ?? ?? ?? ??
  • 10.3 ?? ?? (Topological Sort)
  • 10.4 ?? ?? (Critical Path)
  • ?? (11? 23 ?)
  • 11? ??
  • ?? ??, ?? ??, ?? ??, ?? ??, ? ??
  • ??

2
?? ?? ?? ?? ??(1) (2?)
  • Dki, j ? minDk-1i, j, Dk-1i, k Dk-1k,
    j, k0
  • 1.?? i?? j??? ???? ???? ???? k? ???? ??? ? ??
    ???? ??k? ????? ???? ???? ? ?? ?? Dki, j?
    Dk-1i, j? ??.
  • 2. ?? i?? j??? ???? ??? ???? k? ???? ??? ? ??
    ???? ?? k? ????? ????? ??? (i,k)? (k,j)?? ??
    ????? ?? ? ???? ?? ??? ???? ?? k-1????. ??? ??
    Dki, j? Dk-1i, k Dk-1k, j? ??.

3
?? ?? ?? ?? ??(2)
  • allShortestPath ????

allShortestPath(G, n) // G(V, E), Vn for
(i?0 iltn i?i1) do for (j?0 jltn
j?j1) do Di, j ? weighti, j
// ??? ?? ??? ?? for (k?0
kltn k?k1) do // ?? ???? 0?? k?? ???? ??
for (i?0 iltn i?i1) do // ?? ??? ???
for (j?0 jltn j?j1) do // ??
??? ?? if (Di, j gt (Di,
kDk, j)) then // ?? ?? ???
??????? ?? Di, j ?
Di, kDk, j
end allShortestPath()
4
?? ?? ?? ?? ??(3)
9
0
2
-1
7
4
5
2
4
1
3
1
3
(a) G(V, E)
(b) D-1(weight4,4)
(c) D0
(d) D1
(e) D2
(f) D3
??? G? ?? allShortestPath ????? ?? ??
5
??? ??(1)
  • ??? ??(transitive closure)
  • ???? ?? ?? ??? G?? ??? ? ?? i?? j??? ??? ????? ??
  • ??? ?? ??(D)
  • Di, j 1 ?? i?? j?? ??? 0 ?? ? ?? ??
  • ?? ??? ?? ??(D)
  • Di, j 1 ?? i?? j?? ??? 0 ??? ?? ??

6
??? ??(2)
0
2
3
1
(b) ?? ??(A)
(a) ?? ??? G(V, E)
(c) ??? ?? ??(D )
(d) ?? ??? ?? ??(D1)
?? ??? G? ?? A, D, D
7
??? ??(3)
  • D allShortestPath ???? ??
  • ??? G? ?? lti, jgt? ??? D-1i, j1, ??? D-1i, j
    8? ???
  • ?? ???? D-1i, j lt 8? ?? Di, j 1?? ???,
    D-1i, j 8? ?? Di, j 0? ??
  • D allShortestPath ???? ??
  • D?? Di, i ?? 1? ??
  • ??? ?? ??
  • ?? ??? D? true, false ?? ?? ??? ??
  • Dki, j ? Dk-1i, j OR (Dk-1i, j AND Dkk,
    j), k0

8
?? ??(1)
  • AOV(activity on vertex) ????
  • ???? ?? ??? ???? ?? ???
  • ?? ??, ?? ??? ?? ?? ??
  • ?? ??(precedence relation)
  • ??? ?? ???? ??? ??
  • ???(predecessor)
  • ?? i?? j?? ?? ??? ?? ?, i ? j? ???
  • ?? ???(immediate predecessor)
  • ???(successor)
  • ?? i ?? j?? ?? ??? ?? ?, j? i ? ???
  • ?? ???(immediate successor)

AOV ???? G
9
?? ??
?? ??
0 ????
1 ????
2 ?????
3 ????
4 ????
5 ????
AOV ???? G
10
?? ??(2)
  • ?? ??(partial order)
  • ?????, ????? ?? ??? ?
  • ?? S? S? ?? ?? R?? S? ?? i, j, k? ???,
  • R? S?? ???(transivive) iRj jRk?? ?? iRk? ??
  • R? S?? ????(irreflexive) ?? i? ?? iRi ???? ??
  • ???(asymmetric) iRj??, jRi? ???? ??
  • DAG(directed acyclic graph)
  • ?? ??(topological order)
  • ?? ????? ? ?? i? j? ??, i ? j? ????? ??? i ? j??
    ?? ??? ??? ?? ???

?? ?? 0, 1, 2, 3, 4, 5
0
1
2
3
4
5
?? ??
?? ?? ?
11
?? ??(3)
  • ?? ?? ????

topologicalSort(AOVnetwork, n) // G(V,
E), nV for (i?0 iltn i?i1) do
select u with no predecessor // u?V,
indegree0 if (there is no such u) then
return print(u) remove u and
all arcs incident from u end
topologicalSort
12
?? ??(4)
?? 0 ?? ?? ?? 0 (a)
?? 1 ?? ?? ?? 0, 1 (b)
?? 2 ?? ?? ?? 0, 1, 2 (c)
5
??? ?? ?? ?? 0, 1, 2, 3, 4, 5 (g)
?? 4 ?? ?? ?? 0, 1, 2, 3, 4 (e)
?? 3 ?? ?? ?? 0, 1, 2, 3 (d)
?? 5 ?? ?? ?? 0, 1, 2, 3, 4, 5 (f)
?? ?? ????? ?? ??
13
?? ??(5)
  • ?? ??? ?? ?? ??? ??
  • ?? ?? ???? indegree ?? ??
  • ??? ?? ??? ??
  • ??? ?? ??? ?? ???? ????? ??
  • ???? 0? ???? ?? ??? ???? ??

vertex
link
indegree
vertex
link
0
0
null
2
1
1
1
1
3
3
null
4
0
5
2
1
3
null
4
2
4
3
2
null
5
AOV ???? G
4
2
null
5
5
2
null
?? ??? ?? AOV ???? G? ?? ?? ??? ??
14
?? ??(6)
  • ?? ?? ???? (Java)

class Graph Queue Q // ?? i? ??????
???? ? Queue ZeroPredQ //???? ?? ????
???? ? List sortedList // ?? ?? ???
???? ??? int indegree // ?? i? ????
int n //?? ? public Graph(int
vertices) // ??? n vertices
Q new Queuen // ? ??
zeroPredQ new Queue() sortedList
new List() for (int i0 iltn i)
Qi new Queue() // ? Qi?
?? ??? indegree new
intn
15
?? ??(7)
public void topologicalSort()
int i, v, successor for (i0 iltn
i) if (indegreei0) //
??? ?? zeroPredQ.enqueue(i)
if
(zeroPredQ.isEmpty())
System.out.println(
Write a Comment
User Comments (0)
About PowerShow.com