caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Tilt <cet@webcriteria.com>
To: caml-list@inria.fr
Subject: RE: [Caml-list] Looking for Graph Operations-library
Date: Wed, 26 Sep 2001 14:50:14 -0700	[thread overview]
Message-ID: <6B2758E78474D411958F00D0B78906006A6BD8@kenny.gaggle> (raw)

Although I am not an accomplished functional programmer,
I would be happy to share a parameterized (functor-based)
graph module that provides basic directed graph data
structures and itterators. It allows arbitrary vertex
and edge types with the use of a functor interface. There
is also an accompanying algorithm module that currently
only implements shortest path and a skeleton function.
Let me know it sounds useful. I included the signature
below (sorry for the extra length). Performance is good
even though the vertex and edge maps are purely functional.
A pretty printer uses the graphviz "dot" format. Sorry
there is no parser :-(

Cheers, Chris
mailto:cet@webcriteria.com

(* Module [Pgraph]: graphs over ordered vertex identifiers with
   parameterized vertex, and edge types *)

module type ParameterizedGraphType =
  sig
    type t
      (* type of the vertex identifier *)
    type edge
      (* edge attributes *)
    type vertex
      (* vertex attributes *)
    val compare: t -> t -> int
	(* compare is used to order vid *)
    val formatEdge: t -> t -> edge -> string
    val formatVertex: t -> vertex -> string
  end


module type S =
  sig
    type vid
    type pVertex
    type pEdge
    type vertex = Vertex of vid * pVertex
    type edge = Edge of vid * vid * pEdge
    type t
    type graph = t

    module GraphAttributes : ParameterizedGraphType
    module VertexMap : Map.S with type key = vid

    val empty: t
    val isEmpty: t -> bool
    val numVertices: t -> int
    val numEdges: t -> int
    val vidOf: vertex -> vid
	(* find a vertex by name, throws Not_found if vid not in graph *)
    val vertexOf: vid -> t -> vertex
    val numEdgeDuplicates: vid -> vid -> t -> int
    val firstChildOf: vid -> t -> vid
    val vertexAttributeOf: vid -> t -> pVertex
    val hasVertex: vid -> t -> bool
    val removeAllEdges: t -> t
    val hasEdge: vid -> vid -> t -> bool
    val addVertex: vertex -> t -> t
    val addEdge: edge -> t -> t
	(* addEdgeAccumulate adds/updates an edge where the edge value
	   is the result of applying the supplied accumulator function
	   to the old edge value and supplied edge value *)
    val addEdgeAccumulate: edge -> (edge -> edge -> edge) -> t -> t
    val edges: t -> edge list
    val vertices: t -> vertex list
    val edgesFrom: vid -> t -> edge list
    val edgesTo: vid -> t -> edge list
    val mapVertices: (vertex -> vertex) -> t -> t
	(* applies a mapping function to all vertices in the graph,
	   replacing each vertex in the graph with the result of the
	   function application. Careful if you change the vid *)
    val iterVertices: (vertex -> unit) -> t -> unit
    val iterEdges: (edge -> unit) -> t -> unit
    val formatEdge: edge -> string
    val formatVertex: vertex -> string
    val printDotGraph: string -> out_channel -> t -> unit

  end
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ:
http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives:
http://caml.inria.fr
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


             reply	other threads:[~2001-09-27 11:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-26 21:50 Chris Tilt [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-26 13:06 [Caml-list] Initial port of ocaml for mingw (long) CaptnJamesKirk
2001-09-26 16:44 ` [Caml-list] Looking for Graph Operations-library Mattias Waldau
2001-09-26 16:47 ` Mattias Waldau
2001-09-26 17:08   ` Markus Mottl
2001-09-26 17:13   ` Brian Rogoff
2001-09-26 18:04     ` Mattias Waldau
2001-09-26 18:29       ` Brian Rogoff
2001-09-26 19:23       ` Markus Mottl
2001-09-27  6:16   ` Jean-Christophe Filliatre
2001-10-01 10:00   ` Francois Pottier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6B2758E78474D411958F00D0B78906006A6BD8@kenny.gaggle \
    --to=cet@webcriteria.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).