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
422ac1ce
Commit
422ac1ce
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
[Depreciated] replaceWith()
parent
4b3540a3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/graph/GraphView.cpp
+1
-62
1 addition, 62 deletions
src/graph/GraphView.cpp
with
1 addition
and
62 deletions
src/graph/GraphView.cpp
+
1
−
62
View file @
422ac1ce
...
@@ -531,68 +531,7 @@ void Aidge::GraphView::insertParent(NodePtr childNode,
...
@@ -531,68 +531,7 @@ void Aidge::GraphView::insertParent(NodePtr childNode,
bool
Aidge
::
GraphView
::
replaceWith
(
std
::
set
<
std
::
shared_ptr
<
Node
>>
newNodes
)
{
bool
Aidge
::
GraphView
::
replaceWith
(
std
::
set
<
std
::
shared_ptr
<
Node
>>
newNodes
)
{
// TODO : only supports one input/output node for now
return
GraphView
::
replace
(
mNodes
,
newNodes
);
assert
(
mNodes
.
size
()
>
0
&&
"There must be at least one Node to replace"
);
bool
replacable
;
std
::
shared_ptr
<
Node
>
previousInputNode
=
(
*
inputNodes
().
begin
());
std
::
shared_ptr
<
Node
>
previousOutputNode
=
(
*
outputNodes
().
begin
());
std
::
shared_ptr
<
Node
>
newOutputNode
;
auto
gNew
=
std
::
make_shared
<
GraphView
>
();
gNew
->
add
(
newNodes
,
false
);
if
(
newNodes
.
empty
())
{
replacable
=
(
outputNodes
().
size
()
==
1
)
&&
(
inputNodes
().
size
()
==
1
)
&&
((
*
outputNodes
().
begin
())
->
nbOutputs
()
==
1
)
&&
((
*
inputNodes
().
begin
())
->
nbDataInputs
()
==
1
);
newOutputNode
=
previousInputNode
->
input
(
0
).
first
;
}
else
{
newOutputNode
=
(
*
gNew
->
outputNodes
().
begin
());
replacable
=
(
outputNodes
().
size
()
==
gNew
->
outputNodes
().
size
())
&&
(
outputNodes
().
size
()
==
1
)
&&
(
previousOutputNode
->
nbOutputs
()
==
newOutputNode
->
nbOutputs
());
}
if
(
replacable
)
{
auto
copyOutputs
=
previousOutputNode
->
outputs
();
// manage Views for newNodes
// only keep common views to each node for the new set
std
::
set
<
std
::
shared_ptr
<
GraphView
>>
commonGraphViews
=
(
*
mNodes
.
begin
())
->
views
();
for
(
const
auto
&
nodePtr
:
mNodes
)
{
const
auto
nodeView
=
nodePtr
->
views
();
std
::
set
<
std
::
shared_ptr
<
GraphView
>>
intersection
;
std
::
set_intersection
(
commonGraphViews
.
begin
(),
commonGraphViews
.
end
(),
nodeView
.
begin
(),
nodeView
.
end
(),
std
::
inserter
(
intersection
,
intersection
.
begin
()));
commonGraphViews
=
intersection
;
}
// clean Nodes to replace
std
::
set
<
std
::
shared_ptr
<
Node
>>
copyNode
=
mNodes
;
for
(
auto
&
nodePtr
:
copyNode
)
{
nodePtr
->
resetConnections
(
true
);
}
// copy output connections
if
(
newOutputNode
)
{
for
(
IOIndex_t
o
=
0
;
o
<
previousOutputNode
->
nbOutputs
();
++
o
)
{
auto
outputPairs
=
copyOutputs
[
o
];
for
(
const
auto
&
onePair
:
outputPairs
)
{
newOutputNode
->
addChild
(
onePair
.
first
,
o
,
onePair
.
second
);
}
}
}
// insert new Nodes in the right GraphViews
for
(
auto
&
graphPtr
:
commonGraphViews
)
{
graphPtr
->
add
(
newNodes
,
false
);
if
(
newNodes
.
empty
())
{
graphPtr
->
updateInputNodes
();
graphPtr
->
updateOutputNodes
();
}
}
}
return
replacable
;
}
}
bool
Aidge
::
GraphView
::
replace
(
const
std
::
set
<
Aidge
::
NodePtr
>&
oldNodes
,
const
std
::
set
<
Aidge
::
NodePtr
>&
newNodes
)
{
bool
Aidge
::
GraphView
::
replace
(
const
std
::
set
<
Aidge
::
NodePtr
>&
oldNodes
,
const
std
::
set
<
Aidge
::
NodePtr
>&
newNodes
)
{
...
...
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