nikeee / edotor.net

Your favourite Graphviz editor
https://edotor.net
MIT License
176 stars 21 forks source link

Lists of nodes doesn't work. #46

Open pbsds opened 2 years ago

pbsds commented 2 years ago

This graph doesn't seem to work. Edotor wasn't even able to export a link to that graph. It seems to dislike the comma separated list if nodes.

nikeee commented 2 years ago

Thanks for your feedback! I've taken a look into the grammar of graphviz:

image (src)

If I'm not mistaking, according to the grammar, comma-separated node IDs are not valid. Instead, is says in that page:

Semicolons and commas aid readability but are not required. Also, any amount of whitespace may be inserted between terminals.

So actually, o:a:e, o:b:e -> s01:w, s02:w should be equivalent to o:a:e; o:b:e -> s01:w; s02:w which should be in turn equivalent with o:a:e o:b:e -> s01:w s02:w. That means that - according to that document - it should only connect o:b:e -> s01:w.

You can use sub graphs to get a similar behaviour as you intended:

{o:a:e o:b:e o:c:e f:a:e f:b:e f:c:e f:d:e f:e:e }
    -> {s01:w s02:w s03:w s04:w s05:w}

However, the site you linked uses the same graphivz renderer as edotor, which is actually Graphviz. So it seems that Graphviz itself somehow implements this grammar extension, but the language service that provides auto completion doesn't. If the language service detects an error, no graph is attempted to be rendered (thats why you cannot display/link that graph).

We can address this the following ways / use these workarounds:

  1. Use Subgraph notation (as stated above) as a workaround
  2. Try to render the graph regardless if the language service detects syntactic errors (will keep the document with error markers, but the rendering should work)
  3. Change the parser to recognize that comma separated syntax. This would be the best solution, but we should ask somewhere if this is actually intended syntax.

Whats broken either way is that , is recognized as an error, which seems wrong.

pbsds commented 2 years ago

A maintainer of graphviz (author maybe?) adviced me to use lists instead of subgraphs, due to how subgraph discard the port information (this is a good lint warning rule btw). Source. I vote for both 2 and 3

nikeee commented 2 years ago

due to how subgraph discard the port information.

Yeah, I also noticed that after posting. Thanks for your link, I've asked on their forums about that: https://forum.graphviz.org/t/comma-separated-list-of-node-ids/1085

I've also noticed your comment on the issue. Thanks!

dosmanak commented 4 months ago

Hello. I also use com,a separated list of nodes to have multiple edges to the same node. Funny thing is the Edotor refuse to render the graph when editing, but loads well from cache even with commas. So only the validator complains but the engine is working well.