graph/encoding/dot: reconsider strict parameter on Marshal
Created by: 32bitkid
Background
The Marshal()
function takes a final boolean parameter that will prefix the emitted DOT encoded graph with the strict
keyword. This, according to the DOT documentation:
...forbids the creation of multi-edges, i.e., there can be at most one edge with a given tail node and head node in the directed case. For undirected graphs, there can be at most one edge connected to the same two nodes. Subsequent edge statements using the same two nodes will identify the edge with the previously defined one and apply any attributes given in the edge statement.
Given that a graph.Graph
is the interface for a simple graph, it is not really possible to construct a non-strict DOT graph in this form. A graph.Multigraph
may, or may not, be a strict graph, it depends on the topology of the graph.
Proposal
- Remove the
strict
parameter fromMarshal()
, and makeMarshal(graph.Graph)
always serialize astrict
dot graph. - Remove the
strict
parameter fromMarshalMulti()
and makeMarshalMulti(graph.Multigraph)
always serialize a non-strict graph
This would simplify the arguments for both functions, and reduce the likelihood of serializing an invalid DOT graph.
- Introduce a new pair of helper functions to convert a
graph.Graph
to agraph.Multigraph
and vice-versa. This has an advantage over doingstrict
checking during serialization, as it is an explicit action to perform/verify the conversion, and errors can be handled explicitly, e.g. loading a multigraph and altering it in a way that should result in a simple graph, then outputting it is astrict
DOT graph.
Potential implementation challenges
I'm not quite sure how to transfer custom DOT serialization properties through the conversion process.
Potential impact of proposal
The signature of Marshal()
will change and be incompatible with previous versions.