1 #ifndef GPM_PatternFunction_H
2 #define GPM_PatternFunction_H
28 map<int ,tBoolean> mPVerticesToRemove;
31 map<int ,tBoolean> mPVerticesToKeep;
35 map<int,tBoolean> mPEdgesToRemove;
38 map<int ,tBoolean> mPEdgesToKeep;
42 SV::GPM_Edge mPTEdgesToAdd;
46 vector<tString> mNodeGroupIds;
47 vector<tString> mPortGroupIds;
50 tFlag mUpToAutomorphismType;
89 mPVerticesToRemove.clear();
90 mPVerticesToKeep.clear();
91 mPEdgesToRemove.clear();
92 mPEdgesToKeep.clear();
93 mPTEdgesToAdd.clear();
94 mNodeGroupIds.clear();
95 mPortGroupIds.clear();
96 mIsUpToAutomorphism=
false;
97 mUpToAutomorphismType=0;
105 mUpToAutomorphismType=upToAutomorphismType;
112 return mIsUpToAutomorphism;
117 return mUpToAutomorphismType;
122 mPVerticesToRemove[vid]=
true;
127 mPVerticesToRemove.erase(vid);
132 mPVerticesToKeep[vid]=
true;
137 mPVerticesToKeep.erase(vid);
143 return (mPVerticesToRemove.find(
id)!=mPVerticesToRemove.end());
148 return (mPVerticesToKeep.find(
id)!=mPVerticesToKeep.end());
153 int n=mPTEdgesToAdd.getSize();
154 for (
int i=0;i<n;i++) {
155 if (mPTEdgesToAdd[i]->getSource()->getId()==
id)
return true;
163 mPEdgesToRemove[eid]=
true;
168 mPEdgesToRemove.erase(eid);
173 mPEdgesToKeep[eid]=
true;
178 mPEdgesToKeep.erase(eid);
187 if (edge.get()!=
null)
197 if (edge.get()!=
null)
204 return mPEdgesToRemove;
209 return mPEdgesToKeep;
214 return mPVerticesToRemove;
219 return mPVerticesToKeep;
224 return (mPEdgesToRemove.find(
id)!=mPEdgesToRemove.end());
229 return (mPEdgesToKeep.find(
id)!=mPEdgesToKeep.end());
250 mPTEdgesToAdd.add(edge);
251 edge->setId(mPTEdgesToAdd.getSize()-1);
258 return mPTEdgesToAdd.size();
268 return mPTEdgesToAdd[index];
274 SP::GPM_Edge edge=mPTEdgesToAdd[mPTEdgesToAdd.size()-1];
294 mPTEdgesToAdd.clear();
310 mNodeGroupIds.push_back(name);
315 mNodeGroupIds.erase(mNodeGroupIds.begin()+index);
320 mPortGroupIds.push_back(name);
325 mPortGroupIds.erase(mPortGroupIds.begin()+index);
336 return mNodeGroupIds;
341 return mPortGroupIds;
349 map<int,tBoolean>::const_iterator iter=mPVerticesToRemove.begin();
350 while (iter!=mPVerticesToRemove.end()) {
351 ids.push_back(iter->first);
360 map<int,tBoolean>::const_iterator iter=mPVerticesToKeep.begin();
361 while (iter!=mPVerticesToKeep.end()) {
362 ids.push_back(iter->first);
373 map<int,tBoolean>::const_iterator iter=mPEdgesToRemove.begin();
374 while (iter!=mPEdgesToRemove.end()) {
375 ids.push_back(iter->first);
383 map<int,tBoolean>::const_iterator iter=mPEdgesToKeep.begin();
384 while (iter!=mPEdgesToKeep.end()) {
385 ids.push_back(iter->first);
393 return mPTEdgesToAdd;
398 return mPTEdgesToAdd;
406 const SV::GPM_Vertex& smallGraphVertices,
407 const vector<tVertexIID>& mapping,
415 return (mPVerticesToRemove.find(
id)!=mPVerticesToRemove.end());
420 return (mPVerticesToKeep.find(
id)!=mPVerticesToKeep.end());
425 return (mPEdgesToRemove.find(
id)!=mPEdgesToRemove.end());
430 return (mPEdgesToKeep.find(
id)!=mPEdgesToKeep.end());
442 const vector<tVertexIID>& mappingP2L,
CORE_Out& io) {
444 largeGraph,mappingP2L,
451 const vector<tVertexIID>& mappingP2L,
452 const map<tVertexIID,tVertexIID>& mappingT2L,
CORE_Out& io)=0;
456 const vector<tVertexIID>& mappingP2L,
CORE_Out& io)=0;
462 const vector<tVertexIID>& mappingP2L,
463 const map<tVertexIID,tVertexIID>& mappingT2L,
476 GPM_Graph& largeGraph,
const vector<tVertexIID>& mapping,
void addPTEdgeToAdd(const int &source, const int &target)
add the edge (source,target) source in pattern graph , target in transformed graph ...
Definition: GPM_PatternFunction.h:233
void addVariableNameToNodeGroupId(const tString &name)
add the state to build the group id of node
Definition: GPM_PatternFunction.h:309
GPM_PatternFunction(void)
create an object
Definition: GPM_PatternFunction.cpp:10
virtual tBoolean updatePTEdgesStates(SP::GPM_Edge PTedge, SP::GPM_Edge ledge, GPM_Graph &largeGraph, const vector< tVertexIID > &mappingP2L, const map< tVertexIID, tVertexIID > &mappingT2L, CORE_Out &io)=0
update the states of edges betwen pattern & transform graph
virtual tString toString() const
return the string representation of the class
Definition: GPM_PatternFunction.cpp:392
const map< int, tBoolean > & getPatternEdgesToKeep() const
get the pattern edges list to keep
Definition: GPM_PatternFunction.h:208
tBoolean isEdgeKept(const int &id) const
return true if the edge is keep
Definition: GPM_PatternFunction.h:429
void removeVariableNameToNodeGroupId(const int &index)
remove the state at index to build the group id of node
Definition: GPM_PatternFunction.h:314
virtual tBoolean updatePatternGraphStates(GPM_Graph &largeGraph, const vector< tVertexIID > &mappingP2L, CORE_Out &io)=0
update the states (coordianates,tags...) of the sub graph of the large graph corresponding to pattern...
tFlag getUpToAutomorphismType() const
return the type of graph element to be up to automorphism
Definition: GPM_PatternFunction.h:116
void removePVertexToKeep(const int &vid)
remove the vertex to keep from pattern graph
Definition: GPM_PatternFunction.h:136
tBoolean isUpToAutomorphism() const
return true if the function is up to automorphism
Definition: GPM_PatternFunction.h:111
tGraph::edge_descriptor tEdgeIID
Definition: GPM_Types.h:50
void removePEdgeToRemove(const int &eid)
remove the edge to remove from pattern graph
Definition: GPM_PatternFunction.h:167
const GPM_PortGraph & getTransformerGraph() const
get the transformer graph for reading
Definition: GPM_Function.h:95
void removePTEdgeToAdd(SP::GPM_Edge edge)
remove the edge (source,target)
Definition: GPM_PatternFunction.h:281
void addVariableNameToPortGroupId(const tString &name)
add the state to build the group id of port
Definition: GPM_PatternFunction.h:319
DEFINE_SPTR(GPM_PatternFunction)
virtual tBoolean isMappingValid(const GPM_PortGraph &largeGraph, const SV::GPM_Vertex &smallGraphVertices, const vector< tVertexIID > &mapping, CORE_Out &io) const
return true if the mapping is valid
Definition: GPM_PatternFunction.h:405
void setIsUpToAutomorphism(const tBoolean &isUpToAutomorphism)
set is up to automorphism
Definition: GPM_PatternFunction.h:101
void getPatternVerticesToKeep(vector< int > &ids) const
get the vertices to keep from associated pattern graph
Definition: GPM_PatternFunction.h:358
tBoolean isPEdgeToKeep(const int &id) const
return true if the edge has already a keep trigger action
Definition: GPM_PatternFunction.h:228
void getPatternVerticesToRemove(vector< int > &ids) const
get the vertices to remove from associated pattern graph
Definition: GPM_PatternFunction.h:347
const SV::GPM_Edge & getPatternTransformEdgesToAdd() const
get the edges to ad dfrom pattern graph to transformed graph
Definition: GPM_PatternFunction.h:392
This class describes a patten function.
Definition: GPM_Function.h:20
void getPatternEdgesToKeep(vector< int > &ids) const
get the edges to keep from associated pattern graph
Definition: GPM_PatternFunction.h:381
#define tBoolean
Definition: types.h:35
tBoolean isPVertexMustBeKept(const int &id) const
return true if the vertex must be kept
Definition: GPM_PatternFunction.h:152
void addPVertexToKeep(const int &vid)
add the vertex to keep from pattern graph
Definition: GPM_PatternFunction.h:131
tBoolean isVertexKept(const int &id) const
return true if the vertex is kept
Definition: GPM_PatternFunction.h:419
void setUpToAutomorphismType(const tFlag &upToAutomorphismType)
Definition: GPM_PatternFunction.h:104
#define null
Definition: types.h:13
const map< int, tBoolean > & getPatternVerticesToRemove() const
get the pattern vertices list to remove
Definition: GPM_PatternFunction.h:213
void removePEdgeToKeep(const int &eid)
remove the edge to keep from pattern graph
Definition: GPM_PatternFunction.h:177
const vector< tString > & getNodeGroupIds() const
get the variables names to define the group name of nodes
Definition: GPM_PatternFunction.h:335
virtual void clear()
clear
Definition: GPM_Function.h:65
void addPTEdgeToAdd(SP::GPM_Edge edge)
add the edge (source,target) source in pattern graph , target in transformed graph ...
Definition: GPM_PatternFunction.h:249
void addPEdgeToKeep(const int &source, const int &target)
add the edge to remove from pattern graph
Definition: GPM_PatternFunction.h:183
const vector< tString > & getPortGroupIds() const
get the variables names to define the group name of ports
Definition: GPM_PatternFunction.h:340
const GPM_PortGraph & getPatternGraph() const
get the pattern graph for reading
Definition: GPM_Function.h:76
tBoolean getEdge(const tVertexIID &e1, const tVertexIID &e2, tEdgeIID &iid) const
get edge between vertices e1 & e2
Definition: GPM_Graph.cpp:409
const map< int, tBoolean > & getPatternVerticesToKeep() const
get the pattern vertices list to keep
Definition: GPM_PatternFunction.h:218
void initGroupNames(GPM_PortGraph &graph, CORE_Out &io) const
init the group name id
Definition: GPM_PatternFunction.cpp:267
void removePTEdgeToAddWithTarget(const int &targetId)
remove the edge for pattern &transform graph with target
Definition: GPM_PatternFunction.cpp:380
void clearPTEdgesToAdd()
Definition: GPM_PatternFunction.h:293
tBoolean isVertexCut(const int &id) const
return true if the vertex is cut
Definition: GPM_PatternFunction.h:414
void removePTEdgeToAddWithSource(const int &sourceId)
remove the edge for pattern &transform graph with source
Definition: GPM_PatternFunction.cpp:363
virtual void copy(const GPM_Function &rule)
copy
Definition: GPM_PatternFunction.cpp:21
void removeLastPTEdge()
remove the last edge (source,target) source in pattern graph , target in transformed graph ...
Definition: GPM_PatternFunction.h:273
SP::GPM_Vertex getVertex(const tVertexIID &iid) const
get vertex with internal id
Definition: GPM_Graph.cpp:330
tBoolean isValid() const
return true if the topological rules transformation will build to a valid graph
Definition: GPM_PatternFunction.cpp:278
virtual tBoolean updateTransformerGraphStates(GPM_Graph &largeGraph, const vector< tVertexIID > &mappingP2L, const map< tVertexIID, tVertexIID > &mappingT2L, CORE_Out &io)=0
update the states (coordianates,tags...) of the transformed graph copied in the large graph ...
int getPTEdgesNumber() const
get the number of edges to add
Definition: GPM_PatternFunction.h:257
virtual tBoolean apply(GPM_Graph &largeGraph, const vector< tVertexIID > &mappingP2L, CORE_Out &io)
apply the trnafsormtaion with pattern
Definition: GPM_PatternFunction.h:441
virtual void clear()
clear all topological modification
Definition: GPM_PatternFunction.h:87
tVertexIID getVertexIID(const int &id) const
get the internal id of vertex with id (for convenience use)
Definition: GPM_Graph.cpp:284
void removeVariableNameToPortGroupId(const int &index)
remove the state at index to build the group id of port
Definition: GPM_PatternFunction.h:324
#define tString
Definition: types.h:36
This class describes a graph which is a list of vertices, ports & edges.
Definition: GPM_PortGraph.h:22
tBoolean isPEdgeToRemove(const int &id)
return true if the edge has already a cut trigger action
Definition: GPM_PatternFunction.h:223
void removePVertexToRemove(const int &vid)
remove the vertex to remove from pattern graph
Definition: GPM_PatternFunction.h:126
void addPEdgeToRemove(const int &eid)
add the edge to remove from pattern graph
Definition: GPM_PatternFunction.h:162
This class describes a patten function.
Definition: GPM_PatternFunction.h:20
this class describes the output by default write on standart output
Definition: CORE_Out.h:21
tBoolean isPVertexToKeep(const int &id) const
return true if the vertex has already a keep trigger action
Definition: GPM_PatternFunction.h:147
virtual SP::GPM_Edge newEdge() const
get the edge internal id
Definition: GPM_Graph.h:197
void getPatternEdgesToRemove(vector< int > &ids) const
get the edges to remove from associated pattern graph
Definition: GPM_PatternFunction.h:371
void addPEdgeToKeep(const int &eid)
add the edge to keep from pattern graph
Definition: GPM_PatternFunction.h:172
void addPVertexToRemove(const int &vid)
add the vertex to remove from pattern graph
Definition: GPM_PatternFunction.h:121
DEFINE_SVPTR(GPM_PatternFunction)
This class describes a graph which is a list of nodes & ports.
Definition: GPM_Graph.h:19
SV::GPM_Edge & getPatternTransformEdgesToAdd()
get the edges to ad dfrom pattern graph to transformed graph
Definition: GPM_PatternFunction.h:397
void addPTEdgeToAdd(SP::GPM_Vertex source, SP::GPM_Vertex target)
add the edge (source,target) source in pattern graph , target in transformed graph ...
Definition: GPM_PatternFunction.h:243
tBoolean isEdgeCut(const int &id) const
return true if the edge is cut
Definition: GPM_PatternFunction.h:424
void addPEdgeToRemove(const int &source, const int &target)
add the edge to remove from pattern graph
Definition: GPM_PatternFunction.h:193
const map< int, tBoolean > & getPatternEdgesToRemove() const
get the pattern edges list to remove
Definition: GPM_PatternFunction.h:203
SP::GPM_Edge getPTEdge(const int &index) const
get the i-th edge to add
Definition: GPM_PatternFunction.h:267
tBoolean isPVertexToRemove(const int &id) const
return true if the vertex has already a cut trigger action
Definition: GPM_PatternFunction.h:142
#define tFlag
Definition: types.h:14
virtual ~GPM_PatternFunction(void)
destroy an object.
Definition: GPM_PatternFunction.cpp:18