Some of Conor McBride's works, Diff, Dissect, relate the derivative of data types to their "type of one-hole contexts". That is, if you take the derivative of the type you are left with a data type which shows you how the data type looks from the inside at any given point.
So, for instance, if you have a list (in Haskell)
data List a = [] | a : List a
this corresponds to
data List a = 1 + a * List a
and through a little mathematical magic, the derivative is
data ListDeriv a = List a * List a
which is interpreted to mean that at any point in the list there will be a list to the left and a list to the right. We can zip through the original list by using the derivative data structure.
Now, I'm interested in doing something similar with graphs. A common representation of graphs is a set of vertices and edges, which might be naively implemented with a data type such as:
data Gr a b i = Gr [(i,a)] [(i,i,b)]
If I understand it correctly, a derivative of this data type, with respect to the graph index, i
, should be something like.
data GrDeriv a b i = d/di (Gr a b i)
= d\di ( [a*i] * [b*i^2] )
= (d\di [a*i]) * [b*i^2] ) + [a*i]*(d/di [b*i^2])
= (a* [a*i] * [a*i]) * [b*i^2] )
+ [a*i] * (2*b*i) *[b*i^2]*[b*i^2])
= InNodes { nodesLeft :: [(a,i)]
, nodeLbl :: a
, nodesRight :: [(a,i)]
, edges :: [(b,i,i)] }
| InEdges { nodes :: [(a,i)]
, adjNode :: Either (b,i) (b,i)
, edgesLeft :: [(b,i,i)]
, edgesRight :: [(b,i,i)] }
I got this through the use of the product rule and chain rules for derivatives, and although possibly there are some errors, it seems to follow the general scheme. In this structure you will either be focused on Nodes (InNodes constructor) or Edges (In edges) and given the place you will see the relevant data.
But this isn't what I was hoping for. I was hoping for a construct more closely related to the interface of Martin Erwigs Functional Graph Library. Specifically, I want to see at a node a context representing the label of the node and two adjacency lists, one for outgoing, one for incoming.
Node a b = ([(i,b)],a,[(i,b)])
I do see hope, however, as the adjacency representation has some terms in common with the derivative, the lone lable, a
, at each hole location, the adjacency representation/dissection of each edge.
Since a derivative isn't the same function as the original, but an integration of the derivative is (kindof), is there some sort of integration analogue which will serve to transform the derivative into a collection of node contexts? Not a direct integration to recover the original structure, mind you, but a structure equivalent to the original but in a more algorithm friendly representation.
If there is, I hope that relationship type structures can be specified by some easy "set of vertices and edges" language and I can derive an efficient library for working with that structure. Such an implemenation could be used to study structures "beyond graph theory": hyper graphs, simplicial complexes...
So. Does this idea seem feasible? Useful? Has there been any study into this type of thing which I could read more about?
Addendum
As commented upon by Curtis F, a set of nodes and edges is not exactly a graph. However, all graphs can be represented by such, and I find it common enough presentation. I've seen (the very coarse specification) $G=(V,E)$ used in research that applies graph theory to optimizations of wireless networks in various ways. Here's an open-access example, DRAND*. This raises the question, what is the link between the presentation and how some software might be implemented based upon the research.
That said, I'm not entirely opposed to changing the input spec from $G=(V,E)$ to something else. For instance, given an index type $I$, node labels, $V$, and edge labels, $E$. Then the graph is (approximately) a function from indexes to a label and edge list.
$$ G = I \to (V * I \to E) $$
This, I'm pretty sure can be expressed (Category theory?) as
$$ G = (V * E^{I})^{I} \tag{1} $$
or
$$ G = V^I * E^{I*I} $$
which can be seen as a set of vertices and edges--given enough caveats. However, its not clear if the derivative of $(1)$ is meaningful:
$$ G' = \ln(V * E^{I}) * (V * E^{I})^{I} * (\ln(E) * V * E^{I}) $$
I for one do think it shows some promise, but I lack the sophistication to go further. I know there must be some work out there exploring the connection further.
* In case the link ever breaks, citation: Rhee, Injong, et al. "DRAND: Distributed randomized TDMA scheduling for wireless ad hoc networks." IEEE Transactions on Mobile Computing 8.10 (2009): 1384-1396.