-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make graph payloads mandatory #12
Labels
Comments
The Maybe-based solution interacts better with issue #13. Since the following instance exists, it would allow the use and propagation of metadata by the current implementation. instance Monoid a => Monoid (Maybe a) |
I'm choosing the Maybe-based solution because of issue #13. |
ggazzi
pushed a commit
that referenced
this issue
Apr 7, 2017
Payloads of `TypedGraph`s are still optional, to minimize the necessary changes. Solves issue #12.
ggazzi
pushed a commit
that referenced
this issue
Apr 7, 2017
Payloads of `TypedGraph`s are still optional, to minimize the necessary changes. Solves issue #12.
Solved and merged to master. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rationale
Currently, the payloads of graph nodes and edges are optional. That is, in a
Graph n e
, nodes contain payloads of typeMaybe n
and edges, of typeMaybe e
. There is currently, however, no use for these payloads in Verigraph, not even to allow metadata such as graph layout (since payloads are not handled and propagated by pullbacks, pushouts, overlappings and similar operations).One of the possible uses would be to store attributes and typing information, which would reduce the number of dictionary lookups necessary to handle typed attributed graphs, simplifying code and improving performance. This, however, is not possible with optional payloads, since all nodes and edges need to have this information.
In order to allow this, graphs would need to have mandatory payloads. That is, in a
Graph n e
, nodes would contain payloads of typen
and edges, of typee
. Then, typed attributed graphs could be implemented simply as follows.This implementation pattern has the following advantages:
A single lookup gives all information about a node or edge, simplifying code and improving efficiency.
Most of the Graph API would be immediately applicable to specialized graph types, without the need for separate functions as is currently done in for
TypedGraph
sProposed Changes
First, change the implementation of
Graph
so its has mandatory payloads. The impact of this change in the rest of Verigraph could be handled in two ways, based onGraph () ()
(unit-based) or onGraph (Maybe n) (Maybe e)
(maybe-based).Unit-Based Solution
Since no part of verigraph currently uses the payloads, they could be replaced with unit types whenever they are "ignored" by functions. We'd have, for example:
Maybe-Based Solution
Alternatively, we could displace the assumption of optional payloads to the function signature. That is, whenever
Nothing
is required to be a possible node payload, the type signature containsGraph (Maybe n) e
(analogously for edges). We'd have, for example:The text was updated successfully, but these errors were encountered: