FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/example/dag.cpp at master · Woodsky/cpp-taskflow · GitHub
Woodsky
/
cpp-taskflow
Public
forked from
taskflow/taskflow
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
example
/
dag.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (27 loc) · 902 Bytes
Breadcrumbs
cpp-taskflow
/
example
/
dag.cpp
Copy path
File metadata and controls
34 lines (27 loc) · 902 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
taskflow.hpp
"
#
define
MIN_PER_RANK
1
//
fatness
#
define
MAX_PER_RANK
10
#
define
MIN_RANKS
1
//
height
#
define
MAX_RANKS
20
#
define
PERCENT
20
//
chance to have an edge
int
main
(
void
) {
::srand
(
0
);
int
nodes =
0
;
int
ranks =
MIN_RANKS
+ (
rand
() % (
MAX_RANKS
-
MIN_RANKS
+
1
));
printf
(
"
digraph G {
\n
"
);
for
(
int
i =
0
; i < ranks; i++) {
/*
New nodes of 'higher' rank than all nodes generated till now.
*/
int
new_nodes =
MIN_PER_RANK
+ (
rand
() % (
MAX_PER_RANK
-
MIN_PER_RANK
+
1
));
/*
Edges from old nodes ('nodes') to new ones ('new_nodes').
*/
for
(
int
j =
0
; j < nodes; j++) {
for
(
int
k =
0
; k < new_nodes; k++) {
if
((
rand
() %
100
) <
PERCENT
) {
printf
(
"
%d -> %d;
\n
"
, j, k + nodes);
/*
An Edge.
*/
}
}
}
nodes += new_nodes;
/*
Accumulate into old node set.
*/
}
printf
(
"
}
\n
"
);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL