I'm using sage to print diffrent graphs with a script written in python. I'm trying to write a generic code that allows me to print all the graphs. For example I have :
g1 = graphs.BarbellGraph(9, 4)
g2 = graphs.RandomNewmanWattsStrogatz(12, 2, .3)
The graph depends on the number and type of my parameters and I must adapt my code to make it work with diffrent cases.
My code :
registry = {"graphs": graphs, "digraphs":digraphs}
methodtocall = getattr(registry["graphs"], "BarbellGraph")
result = methodtocall(2,3)
print(result)
with this code I get as a result
graphs.BarbellGraph(2, 3)
my problem is that methodtocall accepts 2 parameters in the code above and I want to change it depending on the number of parameters for the chosen graph. How can I change the code to make it dynamic for the parameters ?
if I have N parameters I want to have
result = methodtocall(param1, ... ,paramN)
thanks in advance