-
Notifications
You must be signed in to change notification settings - Fork 0
Transform Plug‐in
The Transform interface allows implementing algorithms, such as the clustering algorithms, that receive a graph and output a new graph with a different set of nodes and edges.
Default transform plug-ins are Fan-Select and Extract.
The only method that must be overridden to wrote a Transform plug-in is:
Elve::SharedEGraph transform(const Elve::SharedEGraph& eg) override;
An extended graph is given and the method must return an extended graph.
For the engine to comply with the transformation achieved in the plug-in. Proper transform type must be set when calling the ELVE_TRANSFORM macro in the plugin header:
ELVE_TRANSFORM(TransformName,"GUI title","cmd_line_name",Elve::TransformType::OTHER)
There are two transform types:
- SELECTION, only graph selection is modified and transform return same graph as given.
- OTHER, the graph could be fully altered and it is duty of the plug-in to return a copy of the graph, not making any change to the given one
If new plugin folder and files were created using the corresponding template (see Writing Plug‐ins), method implementation should look like this:
SharedEGraph TransformName::transform(const SharedEGraph& eg) {
///ADD YOUR CODE HERE
return eg->clone(eg->graph()); //Identity transform
}
Notice that we don't do a copy of the internal graph here because it is immutable.
Existing code is often to be conserved as it ensures that layouts and look will be transmitted to the new graph. If the transformation type is OTHER then a new graph must be created. Existing SharedData are often to be re-used for the new graph. Like in this small example where we only exclude some nodes from the graph:
SharedEGraph TransformName::transform(const SharedEGraph& eg) {
//Node ids to exclude, could get them from options or from ExtendedGraph::selection
auto excludedIds = NodeIDSet{1,2,3,4};
auto previouslyExcluded = eg->graph()->excluded();
excludedIds.insert(previouslyExcluded.begin(),previouslyExcluded.end()); //Making the union of exclusions
auto g = make_shared<Graph>(
eg->graph()->datas(),
eg->graph()->extraData(), //Preserve extra data
eg->graph()->aliases(), //Preserve aliases
excludedIds //Replace the set of excludedIds by the new one
);
return eg->clone(g); //Ensure looks, layout, positions are preserved
}
For any more details, see ExtendedGraph documentation.
As all plugins, the Transforms can be used from the GUI and the CLI. But please note that since at the moment there is no way to modify plugin options from the GUI, and the Transforms are expected to use plugin options a lot, the GUI would not be of much use here.
ELVE is developed and maintained by the Processor Architecture Lab, EPFL.
You can contact us at elve@groupes.epfl.ch.