Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fault Tree Project
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STAR 2021 Group 6
Fault Tree Project
Commits
aa6b2f31
Commit
aa6b2f31
authored
4 years ago
by
IrinaShcherbakova
Browse files
Options
Downloads
Patches
Plain Diff
depth first search heuristic (H1)
parent
69f23402
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysis/Heuristics/DepthFirstHeuristic.java
+44
-0
44 additions, 0 deletions
analysis/Heuristics/DepthFirstHeuristic.java
with
44 additions
and
0 deletions
analysis/Heuristics/DepthFirstHeuristic.java
0 → 100644
+
44
−
0
View file @
aa6b2f31
package
Heuristics
;
import
FaultTree.BasicEvent
;
import
FaultTree.FaultTree
;
import
FaultTree.*
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
public
class
DepthFirstHeuristic
extends
AbstractFaultTreeVisitor
implements
Heuristic
{
private
Map
<
BasicEvent
,
Integer
>
order
;
private
HashSet
<
FaultTree
>
visited
;
private
int
counter
;
@Override
public
Map
<
BasicEvent
,
Integer
>
getOrder
(
FaultTree
tree
)
{
//flush old values of order, visited and counter in case the same instance of DFS heuristic is used for multiple trees
order
=
new
HashMap
<>();
visited
=
new
HashSet
<>();
counter
=
0
;
visit
(
tree
);
return
this
.
order
;
}
@Override
public
void
visitIntermediateEvent
(
IntermediateEvent
event
)
{
if
(
visited
.
contains
(
event
)){
return
;
}
visited
.
add
(
event
);
visit
(
event
.
left
);
visit
(
event
.
right
);
}
@Override
public
void
visitBasicEvent
(
BasicEvent
event
)
{
if
(!
order
.
containsKey
(
event
))
{
order
.
put
(
event
,
counter
++);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment