[erlang-questions] Undirected graph Library in Erlang

Ulf Wiger (TN/EAB) <>
Fri Aug 29 08:26:23 CEST 2008

Geevarghese Philip skrev:
> Hi,
>   Is there a library for undirected graphs available in Erlang?
> Thanks,
> Philip

Drawing or data representation?

I guess you could use digraph for representation,
depending on what it is that you want to do. You
can either add edges in both directions, or stipulate
that edges are always directed from e.g. smaller to
bigger vertices (relying on the fact that term
ordering in Erlang is always consistent). This would
mean that to find all edges for a particular vertice,
you'd have to check both in_edges and out_edges.
Incidentally, the function digraph:edges(Graph, Vertice)
does just that.

For drawing, a pretty popular choice of tool seems
to be GraphViz, but if you really want a graph layout
program written in Erlang, perhaps Hans Nilsson's
ancient user contrib could get you started:


(I don't know how it fares with undirected graphs
in particular, but I've understood that the really
hard part of drawing graphs is the layout bit.)

Ulf W

More information about the erlang-questions mailing list