# Graphs

Author(s): Francisco Bueno.

Version: 1.10#6 (2004/8/7, 21:46:39 CEST)

Version of last change: 1.9#238 (2003/12/22, 18:25:58 CET)

This module implements utilities for work with graphs

## Usage and interface (`graphs`)

• Library usage: `:- use_module(library(graphs)).`
• Exports:
• Predicates: `dgraph_to_ugraph/2`, `dlgraph_to_lgraph/2`, `edges_to_ugraph/2`, `edges_to_lgraph/2`.
• Regular Types: `dgraph/1`, `dlgraph/1`.
• Other modules used:
• System library modules: `sort`, `graphs/ugraphs`, `graphs/lgraphs`.

## Documentation on exports (`graphs`)

REGTYPE: dgraph/1:

`dgraph(Graph)`

A directed graph is a term `graph(V,E)` where `V` is a list of vertices and `E` is a list of edges (none necessarily sorted). Edges are pairs of vertices which are directed, i.e., `(a,b)` represents `a->b`. Two vertices `a` and `b` are equal only if `a==b`.

Usage: `dgraph(Graph)`

• Description: `Graph` is a directed graph.

REGTYPE: dlgraph/1:

`dlgraph(Graph)`

A labeled directed graph is a directed graph where edges are triples of the form `(a,l,b)` where `l` is the label of the edge `(a,b)`.

Usage: `dlgraph(Graph)`

• Description: `Graph` is a directed labeled graph.

PREDICATE: dgraph_to_ugraph/2:

Usage: `dgraph_to_ugraph(+Graph, -UGraph)`

• Description: Converts `Graph` to `UGraph`.
• The following properties should hold at call time: `+Graph` is a directed graph. (`graphs:dgraph/1`) `-UGraph` is a free variable. (`term_typing:var/1`)
• The following properties should hold upon exit: `+Graph` is a directed graph. (`graphs:dgraph/1`) `-UGraph` is an ugraph. (`ugraphs:ugraph/1`)

PREDICATE: dlgraph_to_lgraph/2:

Usage: `dlgraph_to_lgraph(+Graph, -LGraph)`

• Description: Converts `Edges` to `LGraph`.
• The following properties should hold at call time: `+Graph` is a directed labeled graph. (`graphs:dlgraph/1`) `-LGraph` is a free variable. (`term_typing:var/1`)
• The following properties should hold upon exit: `+Graph` is a directed labeled graph. (`graphs:dlgraph/1`) `-LGraph` is a labeled graph of `term` terms. (`lgraphs:lgraph/2`)

PREDICATE: edges_to_ugraph/2:

Usage: `edges_to_ugraph(+Edges, -UGraph)`

• Description: Converts `Graph` to `UGraph`.
• The following properties should hold at call time: `+Edges` is a list of `pair`s. (`basic_props:list/2`) `-UGraph` is a free variable. (`term_typing:var/1`)
• The following properties should hold upon exit: `+Edges` is a list of `pair`s. (`basic_props:list/2`) `-UGraph` is an ugraph. (`ugraphs:ugraph/1`)

PREDICATE: edges_to_lgraph/2:

Usage: `edges_to_lgraph(+Edges, -LGraph)`

• Description: Converts `Edges` to `LGraph`.
• The following properties should hold at call time: `+Edges` is a list of `triple`s. (`basic_props:list/2`) `-LGraph` is a free variable. (`term_typing:var/1`)
• The following properties should hold upon exit: `+Edges` is a list of `triple`s. (`basic_props:list/2`) `-LGraph` is a labeled graph of `term` terms. (`lgraphs:lgraph/2`)

## Documentation on internals (`graphs`)

REGTYPE: pair/1:

Usage: `pair(P)`

• Description: `P` is a pair `(_,_)`.

REGTYPE: triple/1:

Usage: `triple(P)`

• Description: `P` is a triple `(_,_,_)`.