-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavareminder.rtf
59 lines (58 loc) · 3.09 KB
/
javareminder.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{\rtf1\ansi\ansicpg936\cocoartf1504\cocoasubrtf830
{\fonttbl\f0\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;\red127\green0\blue85;\red106\green62\blue62;\red63\green127\blue95;
\red0\green0\blue192;\red42\green0\blue255;}
{\*\expandedcolortbl;;\csgenericrgb\c49804\c0\c33333;\csgenericrgb\c41569\c24314\c24314;\csgenericrgb\c24706\c49804\c37255;
\csgenericrgb\c0\c0\c75294;\csgenericrgb\c16471\c0\c100000;}
\paperw11900\paperh16840\margl1440\margr1440\vieww20200\viewh13420\viewkind1
\deftab720
\pard\pardeftab720\partightenfactor0
\f0\fs22 \cf0 \cf2 public\cf0 \cf2 static\cf0 \cf2 int\cf0 [] getorder(EdgeWeightedDigraph \cf3 G\cf0 )\cf4 //This should be the right one, according to the original one, if they can get them from stack, then just use something to minus them should also work.\cf0 \
\{\
DepthFirstOrder \cf3 dfs\cf0 = \cf2 new\cf0 DepthFirstOrder(\cf3 G\cf0 );\
\cf2 int\cf0 \cf3 arr\cf0 [];\
\cf3 arr\cf0 =\cf2 new\cf0 \cf2 int\cf0 [\cf3 G\cf0 .V()];\
\cf2 for\cf0 (\cf2 int\cf0 \cf3 i\cf0 =0;\cf3 i\cf0 <\cf3 G\cf0 .V();\cf3 i\cf0 ++) \{\
\cf3 arr\cf0 [\cf3 i\cf0 ]=\cf3 G\cf0 .V()-\cf3 dfs\cf0 .post(\cf3 i\cf0 )-1;\
\}\
\cf2 return\cf0 \cf3 arr\cf0 ;\
\}\
\cf2 public\cf0 \cf2 static\cf0 \cf2 int\cf0 [] getPreorder(EdgeWeightedDigraph \cf3 G\cf0 )\cf4 //Get the wrong sort by \ul Pre\cf0 \ulnone \
\{\
DepthFirstOrder \cf3 dfs\cf0 = \cf2 new\cf0 DepthFirstOrder(\cf3 G\cf0 );\
\cf2 int\cf0 \cf3 arr\cf0 [];\
\cf3 arr\cf0 =\cf2 new\cf0 \cf2 int\cf0 [\cf3 G\cf0 .V()];\
\cf2 for\cf0 (\cf2 int\cf0 \cf3 i\cf0 =0;\cf3 i\cf0 <\cf3 G\cf0 .V();\cf3 i\cf0 ++) \{\
\cf3 arr\cf0 [\cf3 i\cf0 ]=\cf3 dfs\cf0 .pre(\cf3 i\cf0 );\
\}\
\cf2 return\cf0 \cf3 arr\cf0 ;\
\}\
\
\pard\pardeftab720\partightenfactor0
\cf2 for\cf0 (\cf2 int\cf0 \cf3 i\cf0 =0;\cf3 i\cf0 <\cf3 g1\cf0 .V();\cf3 i\cf0 ++) \
\{\
System.\cf5 out\cf0 .print(\cf3 c\cf0 [\cf3 i\cf0 ]+\cf6 " "\cf0 );\
\}\
System.\cf5 out\cf0 .println(\cf6 " "\cf0 );\
\cf3 c\cf0 =\ul getPreorder\ulnone (\cf3 g1\cf0 );\
\cf2 for\cf0 (\cf2 int\cf0 \cf3 i\cf0 =0;\cf3 i\cf0 <\cf3 g1\cf0 .V();\cf3 i\cf0 ++) \
\{\
System.\cf5 out\cf0 .print(\cf3 c\cf0 [\cf3 i\cf0 ]+\cf6 " "\cf0 );\
\}\
System.\cf5 out\cf0 .println(\cf6 " "\cf0 );\
check(\cf3 g1\cf0 ,\cf3 c\cf0 );\
Topological \cf3 top\cf0 =\cf2 new\cf0 Topological(\cf3 g1\cf0 );\
System.\cf5 out\cf0 .print(\cf3 top\cf0 .order());\
System.\cf5 out\cf0 .println(\cf6 " "\cf0 );\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
\cf0 \
\pard\pardeftab720\partightenfactor0
\cf0 check(\cf3 g1\cf0 ,\cf3 c\cf0 );\
\cf3 c\cf0 =\ul getorder\ulnone (\cf3 g1\cf0 );\
\
\pard\pardeftab720\partightenfactor0
\cf2 int\cf0 \cf3 \ul \ulc3 c\cf0 \ulnone [];\
\cf3 c\cf0 =\cf2 new\cf0 \cf2 int\cf0 [\cf3 g1\cf0 .V()];\
\cf2 int\cf0 \cf3 \ul \ulc3 array\cf0 \ulnone [];\
\cf3 array\cf0 =\cf2 new\cf0 \cf2 int\cf0 [\cf3 g1\cf0 .V()];}