
An Algebra of Graphs - lambdasquirrel
https://blogs.ncl.ac.uk/andreymokhov/an-algebra-of-graphs/
======
solidangle
This is very interesting, but not all that surprising to me. Graphs are
closely related to binary relations (on a single set). We can build a binary
relation R such that x R y iff there is a directed edge from vertex x to
vertex y. It is well known that that the binary relations with the union as
the addition, and relational composition (the arrow in the article) as
multiplication form an idempotent semiring. If define another unary operation
as the reflexive transitive closure of a binary relation (adding a directed
edge from a vertex to each reachable vertex) we even form a Kleene algebra,
which allows to reason about graphs in terms of regular expressions and
regular sets.

Another interesting way to represent directed graphs is using matrices over
boolean matrices (also forming an idempotent semiring). Matrices over min, +
algebra (also a Kleene algebra) allow us to represent direct graphs with
weighted edges and allow us to derive many interesting algorithms, such as the
Floyd-Warshall (if we replace the min, + algebra by regular sets we get
Kleene's algorithm instead).

~~~
LolWolf
In particular, you can also endow graphs with lattice structures, which yields
a bunch of of nice monotonicity/fixed-point/ordering theorems over graphs;
computability/hardness of these properties touches some parts of my research
areas.

I do have a bit of a problem representing _arbitrary_ graphs as matrices since
it requires that each graph you're working with be a subgraph of some 'parent
graph,' which is where I think this algebra shines since you're allowed to
construct arbitrary graphs without much mathematical yoga.[1]

Do you have any references/articles you find particularly interesting in the
subjects you mentioned? I'd love to have a bit more in my reading list about
it.

\------

[1] That isn't to say that I'm discounting super useful things like Smith
Normal form, etc.; just that they serve a different purpose than what I
believe this article is trying to get at.

~~~
solidangle
Yes! Graphs have many interesting algebraic properties.

I'm not aware of articles treating graphs as Kleene algebras (I haven't looked
for them though). Conway's "Regular Algebra and Finite Machines" [1] and
Kozen's "A Completeness Theorem for Kleene Algebras and the Algebra of Regular
Events" [2] are interesting texts to read on Kleene algebra.

[1] [https://www.amazon.com/Regular-Algebra-Finite-Machines-
Mathe...](https://www.amazon.com/Regular-Algebra-Finite-Machines-
Mathematics/dp/0486485838)

[2]
[https://www.cs.cornell.edu/~kozen/papers/ka.pdf](https://www.cs.cornell.edu/~kozen/papers/ka.pdf)

~~~
sn0wleopard
solidangle: Indeed, there are a lot of graph algebras out there, and I looked
at many of them, including the Kleene Algebras. So far I haven't found any
algebra with the decomposition axiom, but if you come across one, please let
me know!

Why do I need the decomposition axiom? I haven't actually provided a
motivation for it (or why I defined overlay and connect the way I did). So,
here it is: just like LolWolf, I wanted to represent _arbitrary_ graphs and
_only_ graphs using expressions, so expression x -> y -> z should be just a
graph, and therefore I should be able to construct it from smaller pieces. But
what should these pieces be? We can't make it equal to x -> y + y -> z because
then our definition of -> would be partial, since it's not always possible to
find 'the last node' (in this case y) that we need to connect to z (e.g. the
left-hand side may be a cycle). The only choice that seems to work is to
connect all vertices on the left-hand side to all vertices on the right hand
side, which leads directly to the decomposition axiom.

------
openasocket
Another interesting algebraic structure on graphs is the automorphism group of
graphs. For a graph G, the automorphism group is the set of functions f: G ->
G such that if (and only if) nodes x and y have an edge between them, f(x) and
f(y) have an edge between them. You can think of each such automorphism as a
symmetry of the graph. Some very interesting work has been done with this
abstraction. In fact, I believe the recent paper claiming to solve the Graph
Isomorphism problem in polynomial time makes heavy use of this.

~~~
Chris_Newton
Do you have a reference for that paper about graph isomorphism, please?

~~~
openasocket
[https://arxiv.org/abs/1512.03547](https://arxiv.org/abs/1512.03547)

Note it was actually Quasipolynomial time, not true polynomial time. It's also
a pretty recent paper, so it could turn out to have flaws.

~~~
JadeNB
> It's also a pretty recent paper, so it could turn out to have flaws.

On the other hand, it's Babai, so it doesn't. :-)

------
Chris_Newton
These reminds me of the Functional Graph Library[1] in Haskell, which takes
similar ideas (edit: about constructing graphs inductively) a lot further.

There is also an article by Tikhon Jelvis[2] that provides a nice and
relatively informal introduction to using those ideas in practice.

[1]
[http://hackage.haskell.org/package/fgl](http://hackage.haskell.org/package/fgl)

[2] [http://jelv.is/blog/Generating-Mazes-with-Inductive-
Graphs/](http://jelv.is/blog/Generating-Mazes-with-Inductive-Graphs/)

------
PaulHoule
This is a big deal for RDF-based systems because you could merge, intersect,
and subtract sets of facts quite efficiently this way.

------
amelius
I was hoping this algebra could have physical significance. For example, you
could make a line segment by combining two nodes. You can then combine three
such line segments into a triangle. And then you can combine four triangles
into a tetrahedron. And you can use techniques from differential geometry.
E.g., you could use a "∂" operator to get the boundary of a given structure.
And you can transform the graph into an adjacency matrix, and solve
differential equations.

~~~
lambdasquirrel
I would love to read even a short post on such applications. One thing I
realized while learning abstract math is that abstraction is pretty useless
unless you have things to abstract. You don't need to apply any abstractions
to what you're doing. Leave that to other people.

------
eternalban
The author's Workcraft work looks very interesting:
[http://www.workcraft.org/](http://www.workcraft.org/)

------
JadeNB
The decomposition axiom x \to y \to z = (x \to y) + (x \to z) + (y \to z)
looks to me so much like it wants to be an axiom about lattices, like
distributivity or modularity or something, in disguise; but I don't know much
lattice theory. Is my intuition completely wrong, or could an expert give me
the right translation?

~~~
LolWolf
You're actually very much right, in this case, if we choose z to be the
preferential element (say, the largest, such that x->y iff x≤y), the addition
operation would be the same as 'adding' elements/orderings to the poset in
question; this operation does, in fact, form a lattice.

EDIT: I'd like to say this algebra is more general since in the lattice sense,
any undirected graph is just equivalent to a poset in which all of the
elements are equal (e.g. since x->y+y->x ≅ {x}, where x=y), but there's
obviously more interesting structure than that within the graph. In general,
there's only truly interesting structure within the graph when the graph has a
topological sort (anything else gives elements which are equal under the
partial order).

~~~
JadeNB
Thanks! My question, though, was whether the decomposition axiom is a familiar
lattice axiom (such as modularity or distributivity) in disguise.

~~~
LolWolf
As far as I can tell, I would have to answer that in the negative (see the
EDIT in the previous post). In general, the set of graphs is more
complicated/general than the set of countable/finite lattices (every lattice
can be represented as a DAG by setting a→b iff a∧b=a and b→a iff b∨a=a), which
leads me to believe that there is no obvious isomorphism between operations.

There may be some weirdness where we can take subsets of vertices/edges of
graphs and then endow _those subsets_ with lattice structure, which is somehow
isomorphic to the original graph, but this is again, not obvious to me how it
would be done.

------
egonschiele
Super interesting! I'm looking forward to alga being released -- I've been
looking for a good graph library for a while.

------
GFK_of_xmaspast
See also :
[https://en.wikipedia.org/wiki/Graph_operations](https://en.wikipedia.org/wiki/Graph_operations)

~~~
dbranes
This. The author has discovered the disjoint union and the join. The article
looks correct but comes off a little pretentious for describing some rather
simple (and well-known) things.

------
ajamesm
Leave it to a Haskell coder to make an incomprehensible mess of matrices under
addition.

~~~
wyager
Ironically, I think you failed to comprehend the article. Adjacency matrices
(which you are presumably referring to, but were not mentioned in the article)
are neither efficient nor algebraicly convenient. No one represents graphs as
matrices in computer science, and graph theorists rarely touch representation
theory. It's not that useful when the natural representations are normally
much simpler and easier to work with.

~~~
ajamesm
Oh, yes, we should definitely draw lessons from academic mathematicians about
what is accessible and convenient to understand. THAT's a field that's never
had a problem connecting to laymen.

~~~
Retra
Hard to imagine doing anything interesting if you've got to appeal to laymen
with every word.

