-
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
Change to ByteString to Text and move it into a Value sum type also discuss how to Parameterize the Pangraph type #32
Comments
Additionally my tests did not find increase in runtime to construct or pattern match on Sum types with |
Another thing that maybe worth considering is how to properly represent undirected, directed (I noticed this while implementing #39) and multiple edges. By multiple edges I mean edges that share the same endpoints. |
@zouroboros Regarding multiple edges: we could switch from a list of attributes, to a set of lists of arguments, where each element of the set would correspond to a single edge. As for undirected graphs, it feels like we could just add a Boolean flag to indicate this. |
@snowleopard I think that should work (Sets for multi edges and boolean flags). Maybe there is also a way of pushing pushing this into a type parameter of the Pangraph. So that that the base case of a simple graph is not affected by the additional complexity of the multi edge graph case. |
@thisiswhereitype Regarding the n1 parameter from GraphML files, I think there are two ways:
|
I played a little bit with different graph representations. You can find my work here. Maybe we can use this as a starting point to make the pangraph type more flexible. |
When I implemented this, I opted for
My first step to implementing this was with
The purpose of this code is the unify un-directed, directed and multi-edge graphs under one type? Is it possible to do this with one container by using a sum type on the edge? |
I updated the file to make my points more clear.
Actually my aim was more than this: I wanted to find a a type to represent graphs such that as much as possible about the graph can be deduced from the concrete type. Thats why the graph type is parameterized not only over the edge and vertex labels but also over their container. For example if we consider an (un) directed graph that can be represented as an adjacency matrix. The type of this graph would be: ( Now consider a graph that comes from a pajek file. Pajek files can contain graphs with multiple undirected and directed edges. Hence its type would be Having such a graph type would allow the parse and write functions to more clearly show what kind of graphs they can process. A function that writes graphs into an adjacency matrix would use the type Having a sum type of the undirected and directed edges would defeat this purpose. In case all edges for a graph are needed one can retrieve them via the allEdges function. |
@zouroboros Why? Sorry I don't understand the reason. If you need to support graphs that contain a mix of directed and undirected edges, it feels simpler and more direct to have a special edge attribute (e.g. Perhaps, you'd like to be able to write a function that can only accept graphs with directed edges? Then couldn't you simply treat every undirected edge as two directed? |
I am sorry you are right, I totally forget that we could have three types (undirected, directed and undirected + directed), I somehow thought about only having the sum type. |
The motivation for the @zouroboros Can you re-frame you motivations in this light? I agree however on paramterising the graph similarly to how this thread began. |
I wanted to try to find a representation that expresses as much about the graph as possible on the type level. For example: This thread began with the idea of parametrizing the I thought maybe we can express more about a graph at the type level, hence the idea to not only parametrize the |
As discussed in #29 (Support for GML) a change to Text is needed and using a Value Sum type will useful for working with many kinds of data.
The Pangraph type could be changed:
How will current default implementations work?
GraphML has fields for keys with values such as
n1
where it is nearly a num. Perhaps users can provide a function to return an Int type for their file or if they are not concerned just use Text?In the patch (still to be pushed to my fork) preceding this there is a
ProtoGraph
type which has functions implementing boilerplate code currently required to construct a Graph. A pair of functionscompleteGraph :: Protograph -> (ProtoVertex -> VertexID) -> (ProtoEdge -> (VertexID, VertexID)) -> Maybe Pangraph
andcompleteGraphWithDefault :: Protograph -> Maybe Pangraph
. This could be changed in 0.3.0 to include the value types and return aValueGraph
The text was updated successfully, but these errors were encountered: