Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
jester
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
24eebe3e
authored
May 22, 2020
by
Michael Schmid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Binary dec tree and nfj creation finished
parent
a15a466e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
22 deletions
+73
-22
src/main/java/mvd/jester/model/DagTask.java
+0
-0
src/main/java/mvd/jester/utils/BinaryDecompositionTree.java
+8
-2
src/test/java/mvd/jester/model/TestDagUtils.java
+65
-20
No files found.
src/main/java/mvd/jester/model/DagTask.java
View file @
24eebe3e
This diff is collapsed.
Click to expand it.
src/main/java/mvd/jester/utils/BinaryDecompositionTree.java
View file @
24eebe3e
package
mvd
.
jester
.
utils
;
public
class
BinaryDecompositionTree
<
N
>
{
private
Node
<
N
>
root
;
...
...
@@ -12,6 +13,9 @@ public class BinaryDecompositionTree<N> {
}
public
boolean
contains
(
N
object
)
{
if
(
root
==
null
)
{
return
false
;
}
return
root
.
contains
(
object
);
}
...
...
@@ -75,8 +79,9 @@ public class BinaryDecompositionTree<N> {
/**
* @param leftNode the leftNode to set
*/
public
void
setLeftNode
(
Node
<
T
>
leftNode
)
{
public
Node
<
T
>
setLeftNode
(
Node
<
T
>
leftNode
)
{
this
.
leftNode
=
leftNode
;
return
this
.
leftNode
;
}
/**
...
...
@@ -89,8 +94,9 @@ public class BinaryDecompositionTree<N> {
/**
* @param rightNode the rightNode to set
*/
public
void
setRightNode
(
Node
<
T
>
rightNode
)
{
public
Node
<
T
>
setRightNode
(
Node
<
T
>
rightNode
)
{
this
.
rightNode
=
rightNode
;
return
this
.
rightNode
;
}
/**
...
...
src/test/java/mvd/jester/model/TestDagUtils.java
View file @
24eebe3e
package
mvd
.
jester
.
model
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
org.jgrapht.Graphs
;
import
org.jgrapht.experimental.dag.DirectedAcyclicGraph
;
import
org.jgrapht.graph.DefaultEdge
;
import
org.junit.jupiter.api.DisplayName
;
...
...
@@ -12,20 +13,6 @@ import mvd.jester.utils.BinaryDecompositionTree;
public
class
TestDagUtils
{
@Test
@DisplayName
(
"Test if a NFJ Graph is created correctly."
)
public
void
checkNFJCreation
()
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
DagTaskBuilder
builder
=
new
DagTaskBuilder
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
builder
.
generateTask
().
getJobDag
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
modifiedJobDag
=
DagUtils
.
createNFJGraph
(
jobDag
);
assertTrue
(
DagUtils
.
checkNFJProperty
(
modifiedJobDag
));
}
}
@Test
@DisplayName
(
"Test if dynamic segments are constructed correctly."
)
public
void
checkPathLength
()
{
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
createJobDag
();
...
...
@@ -45,15 +32,73 @@ public class TestDagUtils {
@Test
@DisplayName
(
"Check if NFJ DAGs are created correctly."
)
void
checkNfjDagCreation
()
{
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
DagTaskBuilder
b
=
new
DagTaskBuilder
();
DagTask
t
=
b
.
generateTask
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
nfjDag
=
DagUtils
.
createNFJGraph
(
t
.
getJobDag
());
assertTrue
(
DagUtils
.
checkNFJProperty
(
nfjDag
));
}
}
@Test
@DisplayName
(
"Check if Decomposition Tree is created correctly for NFJ Dag."
)
void
checkDecompositionTreeCreation
()
{
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
createJobDag
();
BinaryDecompositionTree
<
Job
>
tree
=
DagUtils
.
createDecompositionTree
(
jobDag
);
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDagFromTree
=
DagUtils
.
createNFJfromDecompositionTree
(
tree
);
for
(
int
i
=
0
;
i
<
100
;
++
i
)
{
DagTaskBuilder
b
=
new
DagTaskBuilder
();
DagTask
t
=
b
.
generateTask
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDag
=
t
.
getJobDag
();
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
nfjJobDag
=
DagUtils
.
createNFJGraph
(
jobDag
);
BinaryDecompositionTree
<
Job
>
tree
=
DagUtils
.
createDecompositionTree
(
nfjJobDag
);
DirectedAcyclicGraph
<
Job
,
DefaultEdge
>
jobDagFromTree
=
DagUtils
.
createNFJfromDecompositionTree
(
tree
);
assertTrue
(
jobDag
.
vertexSet
().
equals
(
nfjJobDag
.
vertexSet
()));
assertTrue
(
jobDag
.
vertexSet
().
equals
(
jobDagFromTree
.
vertexSet
()));
assertTrue
(
jobDagFromTree
.
edgeSet
().
size
()
==
nfjJobDag
.
edgeSet
().
size
());
for
(
DefaultEdge
e
:
nfjJobDag
.
edgeSet
())
{
Job
target
=
nfjJobDag
.
getEdgeTarget
(
e
);
Job
source
=
nfjJobDag
.
getEdgeSource
(
e
);
assertTrue
(
jobDagFromTree
.
containsEdge
(
source
,
target
));
}
for
(
Job
j
:
nfjJobDag
)
{
for
(
Job
n
:
nfjJobDag
)
{
if
(
n
==
j
)
{
continue
;
}
if
(
nfjJobDag
.
containsEdge
(
n
,
j
))
{
assertTrue
(
jobDagFromTree
.
containsEdge
(
n
,
j
));
}
}
assertTrue
(
nfjJobDag
.
inDegreeOf
(
j
)
==
jobDagFromTree
.
inDegreeOf
(
j
));
assertTrue
(
nfjJobDag
.
outDegreeOf
(
j
)
==
jobDagFromTree
.
outDegreeOf
(
j
));
for
(
Job
p
:
Graphs
.
predecessorListOf
(
nfjJobDag
,
j
))
{
assertTrue
(
Graphs
.
predecessorListOf
(
jobDagFromTree
,
j
).
contains
(
p
));
}
for
(
Job
s
:
Graphs
.
successorListOf
(
jobDagFromTree
,
j
))
{
assertTrue
(
Graphs
.
successorListOf
(
jobDagFromTree
,
j
).
contains
(
s
));
}
for
(
Job
a
:
nfjJobDag
.
getAncestors
(
nfjJobDag
,
j
))
{
assertTrue
(
jobDagFromTree
.
getAncestors
(
jobDagFromTree
,
j
).
contains
(
a
));
}
for
(
Job
d
:
nfjJobDag
.
getDescendants
(
nfjJobDag
,
j
))
{
assertTrue
(
jobDagFromTree
.
getDescendants
(
jobDagFromTree
,
j
).
contains
(
d
));
}
}
assertTrue
(
jobDag
.
equals
(
jobDagFromTree
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment