-
Notifications
You must be signed in to change notification settings - Fork 1
3 Implementation
If you have done all the steps mentioned in "Project Setup", your algorithm java class file (here we use MyAlgorithm.java) should look like this:
public class MyAlgorithm {
}
Now we want to extend the 'AbstractAlgorithm' class from the vigral_plugins_framework, so your code should now look like this:
import java.util.ArrayList;
import de.chiller.vigral.algorithm.AbstractAlgorithm;
import de.chiller.vigral.graph.ElementType;
import de.chiller.vigral.graph.GraphElement;
import de.chiller.vigral.util.Pair;
public class MyAlgorithm extends AbstractAlgorithm {
@Override
public String getAlgorithmName() {
// TODO Auto-generated method stub
return null;
}
@Override
public ArrayList<Pair<ElementType, String>> getRequirements() {
// TODO Auto-generated method stub
return null;
}
@Override
public void perform() {
// TODO Auto-generated method stub
}
@Override
public void setRequirements(ArrayList<GraphElement> arg0) {
// TODO Auto-generated method stub
}
}
So, what are these methods for?
-
getAlgorithmName(): The String this method return is used as the name of your algorithm and is displayed in the dropdown element of the Software Vigral.
-
getRequirements(): Here you should return, what information the algorithm needs to start doing whatever you algorithm does, e.g. a startnode and endnode for finding the shortest path between. if you need nothing, you can return 'null'.
-
setRequirements(): Here you will get the information, that you have queried with the 'getRequirements()' method in that exact same order.
-
perform(): This is the implementaion of the algorithm and is called, after the get and set requirements are called.
For detailed information on the correct way implementing these methods, you should take a look at the code documentation.