Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProgrammationParallelle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Arrêt du service - 11/07 de 07h30 à 07h45 - Mise à jour de sécurité
Show more breadcrumbs
JACQUIER Timeo
ProgrammationParallelle
Commits
59389d57
Commit
59389d57
authored
2 years ago
by
Martin
Browse files
Options
Downloads
Patches
Plain Diff
ajout suffixe tree
parent
ac719a65
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ProgrammesEnVrac/main.cpp
+4
-1
4 additions, 1 deletion
src/ProgrammesEnVrac/main.cpp
src/ProgrammesEnVrac/suffixe_tree.cpp
+151
-0
151 additions, 0 deletions
src/ProgrammesEnVrac/suffixe_tree.cpp
with
155 additions
and
1 deletion
src/ProgrammesEnVrac/main.cpp
+
4
−
1
View file @
59389d57
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
#include
<omp.h>
#include
<omp.h>
#include
"suffixe_tree.cpp"
#define CHRONO
#define CHRONO
using
namespace
std
;
using
namespace
std
;
...
@@ -218,7 +220,8 @@ uint64_t nbAdditifWithSommeOpenMp(int nb){
...
@@ -218,7 +220,8 @@ uint64_t nbAdditifWithSommeOpenMp(int nb){
int
main
(){
int
main
(){
parseFile
(
"testfiles/100000_with_erro.txt"
);
//parseFile("testfiles/100000_with_erro.txt");
parseFile
(
"ACF_1000000_over_0123.txt"
);
#ifdef CHRONO
#ifdef CHRONO
high_resolution_clock
::
time_point
t1
=
high_resolution_clock
::
now
();
high_resolution_clock
::
time_point
t1
=
high_resolution_clock
::
now
();
...
...
This diff is collapsed.
Click to expand it.
src/ProgrammesEnVrac/suffixe_tree.cpp
0 → 100644
+
151
−
0
View file @
59389d57
// Include header file
#include
<iostream>
#include
<string>
#include
<vector>
// C++ program for
// Suffix tree implementation
using
namespace
std
;
class
TreeNode
{
public:
string
sub
;
vector
<
int
>
child
;
TreeNode
()
{
this
->
sub
=
""
;
}
};
class
SuffixTree
{
public:
vector
<
TreeNode
*>
nodes
;
SuffixTree
(
string
data
)
{
this
->
nodes
.
push_back
(
new
TreeNode
());
// Construct tree
this
->
buildTree
(
data
);
}
void
addSuffix
(
string
suf
)
{
// Declare some useful auxiliary variables
int
n
=
0
;
int
i
=
0
;
int
x2
=
0
;
int
n2
=
0
;
int
n3
=
0
;
int
j
=
0
;
TreeNode
*
temp
=
NULL
;
bool
process
=
true
;
string
sub2
=
""
;
while
(
i
<
suf
.
length
())
{
char
b
=
suf
[
i
];
while
(
process
)
{
if
(
x2
==
this
->
nodes
[
n
]
->
child
.
size
())
{
n2
=
this
->
nodes
.
size
();
temp
=
new
TreeNode
();
temp
->
sub
=
suf
.
substr
(
i
);
this
->
nodes
.
push_back
(
temp
);
this
->
nodes
[
n
]
->
child
.
push_back
(
n2
);
return
;
}
n2
=
this
->
nodes
[
n
]
->
child
.
at
(
x2
);
if
(
this
->
nodes
.
at
(
n2
)
->
sub
[
0
]
==
b
)
{
process
=
false
;
}
else
{
x2
++
;
}
}
sub2
=
this
->
nodes
.
at
(
n2
)
->
sub
;
process
=
true
;
while
(
j
<
sub2
.
length
()
&&
(
i
+
j
)
<
suf
.
length
()
&&
process
==
true
)
{
if
(
suf
[
i
+
j
]
!=
sub2
[
j
])
{
n3
=
n2
;
n2
=
this
->
nodes
.
size
();
temp
=
new
TreeNode
();
temp
->
sub
=
sub2
.
substr
(
0
,
j
);
temp
->
child
.
push_back
(
n3
);
this
->
nodes
.
push_back
(
temp
);
this
->
nodes
.
at
(
n3
)
->
sub
=
sub2
.
substr
(
j
);
this
->
nodes
.
at
(
n
)
->
child
.
at
(
x2
)
=
n2
;
process
=
false
;
}
else
{
j
++
;
}
}
i
+=
j
;
n
=
n2
;
// Reset value
x2
=
0
;
n2
=
0
;
n3
=
0
;
j
=
0
;
temp
=
NULL
;
process
=
true
;
sub2
=
""
;
}
}
void
buildTree
(
string
str
)
{
for
(
int
i
=
0
;
i
<
str
.
length
();
++
i
)
{
this
->
addSuffix
(
str
.
substr
(
i
));
}
}
void
printData
(
int
n
,
string
prefix
)
{
vector
<
int
>
children
=
this
->
nodes
[
n
]
->
child
;;
if
(
children
.
empty
())
{
cout
<<
"⤑ "
<<
this
->
nodes
.
at
(
n
)
->
sub
<<
endl
;
return
;
}
cout
<<
"┐ "
<<
this
->
nodes
.
at
(
n
)
->
sub
<<
endl
;
for
(
int
i
=
0
;
i
<
children
.
size
()
-
1
;
i
++
)
{
int
c
=
children
.
at
(
i
);
cout
<<
prefix
<<
"├─"
;
this
->
printData
(
c
,
prefix
+
"│ "
);
}
cout
<<
prefix
<<
"└─"
;
this
->
printData
(
children
.
at
(
children
.
size
()
-
1
),
prefix
+
" "
);
}
void
visualize
()
{
if
(
this
->
nodes
.
empty
())
{
cout
<<
"
\n
Empty Tree"
;
return
;
}
this
->
printData
(
0
,
""
);
}
};
int
main
()
{
// Create Suffix Tree
SuffixTree
*
tree1
=
new
SuffixTree
(
"coconut"
);
SuffixTree
*
tree2
=
new
SuffixTree
(
"BAABAIAIIBI"
);
// Print path
tree1
->
visualize
();
tree2
->
visualize
();
return
0
;
}
\ No newline at end of file
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