Repository navigation
Resolve Issue 75 - #77
james-d-mitchell wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #77 +/- ##
==========================================
- Coverage 90.30% 90.24% -0.06%
==========================================
Files 12 12
Lines 1289 1302 +13
==========================================
+ Hits 1164 1175 +11
- Misses 125 127 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ruthhoffmann
left a comment
There was a problem hiding this comment.
This might sound silly, but
do you really need to "overload" the function for each type of Graphviz concept? Seems a bit inefficient, but if that's the way then I'm OK with this PR.
Good point, perhaps this isn't the correct solution, let me look at the code some more (I'm going to a lecture from 11 to 12, but back after that). |
|
@ruthhoffmann looking into this a little further, it seems that the return value of |
b708b5c to
29e83fe
Compare
|
The plan from yesterday sounds good to me! (github was dodgy and this comment must not have sent yesterday apologies!) |
dvberkel
left a comment
There was a problem hiding this comment.
I would love to see a small update to the error message
| attr := SplitString(str, "="); | ||
| if Length(attr) <> 2 then | ||
| ErrorFormatted("expected a string of the form \"attribute_name=value\", ", | ||
| "but the input string {} does not contain \"=\"", str); |
There was a problem hiding this comment.
If the input string contains more than 1 =, e.g. "i=like=bananas", it will also fail, with the message
expected a string of the form "attribute_name=value" but the input string i=like=bananas does not contain "="
This is obviously an incorrect statement.
An alternative could be
expected a string of the form "attribute_name=value" but the input string i=like=bananas does not adhere
There was a problem hiding this comment.
We agreed with @dvberkel that its probably best to skip argument checking in the 2 argument form at the moment for simplicity. So we leave it up to the user to supply a reasonable 2nd argument and simply add it to the attrs array as is.
There was a problem hiding this comment.
I'm not sure that that is consistent with the other methods though, I'm off to teach until 2, so can't do anything right away. I think "parsing" the string is consistent with the other 2 arg SetAttr, which is a little further down the same file (and probably does a better job than the version in this PR).
|
Thinking about this a bit more, I think we are using the term "attribute" too loosely in the package so far. I think when we are doing things like we are really just telling this would also subsume #38 since I'd be able to do things like: If we make this change, then every object can have an One downside is:
I'd propose to then remove the 2-arg version of We could then additionally implement: as helpers. What do you think @reiniscirpons, @ruthhoffmann, and @dvberkel ? |
|
To me |
|
Thanks @fingolfin any opinion on the other things proposed? |
|
This is a good suggestion. Vis a vis nomenclature @ruthhoffmann thinks that something like Also, in the name of simplicity we could also have the regular Which would be equivalent to Looking at the graphviz lang spec (https://graphviz.org/doc/info/lang.html), there are actually only 3 kinds of "scoped" attributes that can be set to apply to the subgraph as well as its nodes or edges: And these are reserved keywords so we cannot have an attribute named like this, and it should be safe. I agree with making every |
|
How about I think I'll start by making |
|
Do we need to preserve this behavior? We provide mechanisms now via contexts etc where if we wanted to have some nodes be styled one way, we simply make a context for them where they get colored and move on. I'm in general not sure we should allow a user to create an arbitrary graphviz file, rather we should restrict it to a sane subset of the language I think. What do you think @ruthhoffmann @dvberkel? Specifically the question is whether we want something like g := GraphvizGraph();
GraphvizAddNode(g, 1);
GraphvizAddNode(g, 2);
GraphvizSetAttr(g, "node [style=filled]");
GraphvizAddNode(g, 3);
GraphvizAddNode(g, 4);to produce or The first will have nodes 1 and 2 plain and nodes 3 4 filled, but the second will have all four nodes filled.
This seems good |
|
I'm trying to untangle these two things, but it's seemingly not possible. So, I think I'll implement |
|
The former should only be ever done with subgraphs or contexts. |
|
Agreed, I'm implementing |
|
This is a fairly big change, and I'm getting a bit tired, so I'm going to stop after I type this for today. It seems to me that we should actually have 3 concepts here:
As such it might make sense to remove
What do you guys think? Since this is a pretty major change, I wanted to check first. This will also interact really badly if you resolve #115 concurrently, so it might be worthwhile holding off on that. |
This is sort-of true but the grouping of nodes and the collections of nodes, and similarly edges and sets of edges is too much. According to the language spec (https://graphviz.org/doc/info/lang.html) we have two concepts:
These are always denoted by an attribute list of the form
In particular, I think we should keep Then the functions GraphvizSetNodeAttr, GraphvizSetEdgeAttr, GraphvizSetGraphAttr etc can just be convenience wrappers around |
|
Thanks for the comments @reiniscirpons, with your proposal, if I have a graph or digraph, how would I set an attribute for all nodes? I.e. how would I specify this to |
|
@james-d-mitchell I think we should do a meeting and discuss this, I sent you a message on Signal. But to answer your question we special case the attributes |
|
We have a way forward, I'll implement when I'm back from class. |
|
@james-d-mitchell looks like I wont finish my PR for #115 in time, so go ahead with this PR, I will incorporate changes you make into my PR after. |
|
Superseded by #122 |
This should resolve #75, I also added normalization of the whitespace in
GraphvizSetAttr, which meant that some of the tests needed to be rewritten.