Washi1337 / Rivers

A fast graphing library that allows for constructing, importing, exporting, and analysing graph structures in .NET.
MIT License
135 stars 25 forks source link

Single word attributes that start with digits are not quoted #7

Closed holly-hacker closed 4 years ago

holly-hacker commented 4 years ago

If I add UserData starting with 0x to a node or edge, Rivers will not quote it. Certain viewers (such as xdot) will try to read these attributes as integers and crash.

Example:

strict digraph {
"_0001" [label=Add];    // works
"_0002" [label=0x70];   // does not work
"_0003" [label="0x70"]; // works
}

As a temporary workaround, I can pad the values with spaces.

Washi1337 commented 4 years ago

Seems I disregarded one important detail in the specification of the dot language.

The specification states:

An ID is one of the following:

  • Any string of alphabetic ([a-zA-Z\200-\377]) characters, underscores ('_') or digits ([0-9]), not beginning with a digit

As a consequence:

strict digraph {
    0x0 -> 0x1
}

Should be parsed as 3 nodes (0, x0, x1) and one edge between x0 and 0. The same holds for the user attributes, as they use the same ID terminal.