Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cyril Moineau
aidge_core
Commits
8d0dd5ed
Commit
8d0dd5ed
authored
1 year ago
by
vincent lorrain
Browse files
Options
Downloads
Patches
Plain Diff
add appliedRecipes
parent
0686c4ed
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
include/aidge/graphRegex/GraphRegex.hpp
+24
-4
24 additions, 4 deletions
include/aidge/graphRegex/GraphRegex.hpp
src/graphRegex/GraphRegex.cpp
+22
-4
22 additions, 4 deletions
src/graphRegex/GraphRegex.cpp
with
46 additions
and
8 deletions
include/aidge/graphRegex/GraphRegex.hpp
+
24
−
4
View file @
8d0dd5ed
...
...
@@ -11,6 +11,11 @@
namespace
Aidge
{
/**
* type for recipes function use in query and resolve
*/
using
RecipesFunctionType
=
std
::
function
<
void
(
std
::
shared_ptr
<
MatchSolution
>
)
>
;
/**
* @brief class which is the hight level interface for graph matching, used to simplify match definition
*
...
...
@@ -19,9 +24,10 @@ class GraphRegex{
private:
std
::
vector
<
std
::
string
>
mQuery
;
//
std::vector<std::string> mQuery;
std
::
vector
<
std
::
shared_ptr
<
ConditionalInterpreter
>>
mAllTest
;
std
::
map
<
std
::
string
,
std
::
function
<
bool
(
NodePtr
)
>>
mAllLambda
;
std
::
map
<
std
::
string
,
RecipesFunctionType
>
mQueryRecipe
;
public:
GraphRegex
(){};
...
...
@@ -31,7 +37,15 @@ class GraphRegex{
* @brief add a topology query to the match
* @param query the topology query to find
**/
void
addQuery
(
const
std
::
string
query
);
//void addQuery(const std::string query);
/**
* @brief add a topology query to the match and a function for recipe
* @param query the topology query to find
* @param f the funct
**/
void
addQuery
(
const
std
::
string
query
,
RecipesFunctionType
f
=
nullptr
);
/**
* @brief get all the types of a graph and set it as type key in the query
...
...
@@ -53,13 +67,19 @@ class GraphRegex{
**/
void
setNodeKey
(
const
std
::
string
key
,
std
::
function
<
bool
(
NodePtr
)
>
f
);
/**
*
/**
* @brief brief match the queries in the graph
* @param
Reference
the graph were the querys in search
* @param
ref
the graph were the querys in search
* @return the result
*/
std
::
set
<
std
::
shared_ptr
<
MatchSolution
>>
match
(
std
::
shared_ptr
<
GraphView
>
ref
);
/***
* @brief match the queries in the graph and applied the recipes fuction
* @param ref the graph were the querys in search
*/
void
appliedRecipes
(
std
::
shared_ptr
<
GraphView
>
ref
);
private
:
void
_generateCombinationsStart
(
const
std
::
set
<
NodePtr
>&
elements
,
std
::
size_t
n
,
std
::
size_t
index
,
...
...
This diff is collapsed.
Click to expand it.
src/graphRegex/GraphRegex.cpp
+
22
−
4
View file @
8d0dd5ed
...
...
@@ -26,10 +26,17 @@ void GraphRegex::setKeyFromGraph(std::shared_ptr<GraphView> ref){
void
GraphRegex
::
addQuery
(
const
std
::
string
query
){
mQuery
.
push_back
(
query
);
}
// void GraphRegex::addQuery(const std::string query){
// //TODO one query only but the same string is a same query but
// //2 different string it's maybe the same query , we need to check the AST
// mQueryRecipe[query] = nullptr;
// }
void
GraphRegex
::
addQuery
(
const
std
::
string
query
,
RecipesFunctionType
f
){
mQueryRecipe
[
query
]
=
f
;
}
// Function to generate all combinations of n elements from a set
...
...
@@ -87,7 +94,9 @@ std::set<std::shared_ptr<MatchSolution>> GraphRegex::match(std::shared_ptr<Graph
std
::
vector
<
std
::
shared_ptr
<
MatchSolution
>>
solutions
=
{};
for
(
const
std
::
string
&
query
:
mQuery
)
{
//for (const std::string& query : mQuery) {
for
(
auto
it
=
mQueryRecipe
.
begin
();
it
!=
mQueryRecipe
.
end
();
++
it
)
{
const
std
::
string
query
=
it
->
first
;
std
::
shared_ptr
<
GraphFsmInterpreter
>
fsmGenerator
=
std
::
make_shared
<
GraphFsmInterpreter
>
(
query
,
mAllTest
);
std
::
shared_ptr
<
FsmGraph
>
fsm
=
fsmGenerator
->
interpret
();
...
...
@@ -108,6 +117,15 @@ std::set<std::shared_ptr<MatchSolution>> GraphRegex::match(std::shared_ptr<Graph
return
_findLargestCompatibleSet
(
solutions
);
}
void
GraphRegex
::
appliedRecipes
(
std
::
shared_ptr
<
GraphView
>
ref
){
std
::
set
<
std
::
shared_ptr
<
MatchSolution
>>
matchRef
=
match
(
ref
);
for
(
const
auto
&
solution
:
matchRef
)
{
if
(
mQueryRecipe
[
solution
->
getQuery
()]
!=
nullptr
){
mQueryRecipe
[
solution
->
getQuery
()](
solution
);
}
}
}
void
GraphRegex
::
setNodeKey
(
const
std
::
string
key
,
const
std
::
string
conditionalExpressions
){
mAllTest
.
push_back
(
std
::
make_shared
<
ConditionalInterpreter
>
(
key
,
conditionalExpressions
));
_majConditionalInterpreterLambda
();
...
...
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