The program should be able to print a SFG in a way so that is clear to the user that the data printed is a SFG. The representation should contain any data relevant to the evaluation and representation of the SFG.
Linked Requirements:
( 31 )
Potential Issues:
The data to be printed is currently unknown and might depend on previous implementation of #12 (closed).
I thought it should be presented as the first comment in this issue. In one row one operation is presented with it's name, id, the input signals and output signals. Then the next row next operation should be presented in the same way.
The name of the operation might be empty in the general case, so perhaps id should be printed before name in the ordering?
The way id's are generated now the usually look like "add1", while the name can be anything.
Inputs aren't signals but they are operations, so in your example SFG then there should be boxes before the "in-signals" that are input operations and there should be signals with ids like "s1", "s2", "s3", "s4". The same is the case for Outputs.
Since Inputs and Outputs also are operations then perhaps they should be printed as well? Or maybe not, @ivaha717 mentioned that they should be hidden, anyway this should also be decided.
When you print which signals that are connected as input, outputs, then you mean the id's for signals connected right?
I also think that the output perhaps should be changed slightly for better readability, for example: "name: add1, id: 1, input: [in1, in2], output: [s5]" with comma separation and '[]' for multiple values or
"name: add1 id: 1 input: in1, in2 output: s5" with a couple of spaces of spacing between parameters (looks like markdown stripped the extra spaces before rendering... well maybe you get what I mean), what do you think?
Also I was wondering if the printing of the different operations will be done in a specific order or not? For the user it's better if operations close to each other are printed after one another but might be hard to implement in a clean way.
I don't think typename is necessary. Just printing id and name should be sufficient.
Yes, but as mentioned they probably shouldn'y be included in the printing anyway.
A correct topological order isn't really possible since there can be feedback loops, but it could be done so that the last connection that establishes the feedback is "ignored", and then we can have an almost perfect topological order.
Perhaps... But it's not really a priority so just printing via a normal traversal should be sufficient for now I think. However I'm not sure if a DFS or BFS traversal would be better. With a DFS traversal then you would get a good idea of how one input maps to one output, but with BFS you would get a better idea of how operations close to each other are connected. I think DFS implementation would be better, but what do you think?
I get what you think but wouldn't it exist a list of all operations for a sfg? In that case we can get all information from that list and just print it as the id order. The disadvantages will be if an operation has added at a later moment but the most time that will not happend.
I don't think that SFG currently stores a list with the operations currently, I think it only stores a dictionary that maps id to operation and a dictionary that maps name to a list of operations with that name.
Also I see that in your example output you print "id: 1" when id should be "add1". Typename is a string that defines what type of operation it is, so currently it's just "add". Otherwise it looks good.
You could iterate over the dictionary, but then the printing of the outputs would be in "random" order as a dictionary isn't ordered in any specific way. So traversing with DFS and then printing would probably be optimal.
I discussed this with @ivaha717 and he said the he could make it so that SFG saves a list of the operations in correct topological order, so that you could just iterate over them when printing. Not sure when it would be implemented, but if when it's implemented then it would be better to iterate over that list than to traverse with DFS.
It fails since you are not actually returning anything from the sfg method just printing. It might also be a good idea to use the actual toString method in python by overriding the __str__ method, then we will just need to do print(sfg) instead of calling the method.