# Graphs

**Author(s):**Francisco Bueno.

This module implements utilities for work with graphs

## Usage and interface

**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`.

**Imports:***System library modules:*`sort`,`ugraphs`,`lgraphs`.*Packages:*`prelude`,`nonpure`,`condcomp`,`assertions`,`basicmodes`,`regtypes`.

## Documentation on exports

`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)`

Graph is a directed graph.

`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)`

Graph is a directed labeled graph.

**Usage:**`dgraph_to_ugraph(Graph,UGraph)`

Converts Graph to UGraph.

*The following properties should hold at call time:*

(term_typing:nonvar/1)Graph is currently a term which is not a free variable.

(term_typing:var/1)UGraph is a free variable.

(graphs:dgraph/1)Graph is a directed graph.

(term_typing:var/1)UGraph is a free variable.*The following properties should hold upon exit:*

(graphs:dgraph/1)Graph is a directed graph.

(ugraphs:ugraph/1)UGraph is an ugraph.

**Usage:**`dlgraph_to_lgraph(Graph,LGraph)`

Converts Edges to LGraph.

*The following properties should hold at call time:*

(term_typing:nonvar/1)Graph is currently a term which is not a free variable.

(term_typing:var/1)LGraph is a free variable.

(graphs:dlgraph/1)Graph is a directed labeled graph.

(term_typing:var/1)LGraph is a free variable.*The following properties should hold upon exit:*

(graphs:dlgraph/1)Graph is a directed labeled graph.

(lgraphs:lgraph/2)LGraph is a labeled graph of term terms.

**Usage:**`edges_to_ugraph(Edges,UGraph)`

Converts Graph to UGraph.

*The following properties should hold at call time:*

(term_typing:nonvar/1)Edges is currently a term which is not a free variable.

(term_typing:var/1)UGraph is a free variable.

(basic_props:list/2)Edges is a list of pairs.

(term_typing:var/1)UGraph is a free variable.*The following properties should hold upon exit:*

(basic_props:list/2)Edges is a list of pairs.

(ugraphs:ugraph/1)UGraph is an ugraph.

**Usage:**`edges_to_lgraph(Edges,LGraph)`

Converts Edges to LGraph.

*The following properties should hold at call time:*

(term_typing:nonvar/1)Edges is currently a term which is not a free variable.

(term_typing:var/1)LGraph is a free variable.

(basic_props:list/2)Edges is a list of triples.

(term_typing:var/1)LGraph is a free variable.*The following properties should hold upon exit:*

(basic_props:list/2)Edges is a list of triples.

(lgraphs:lgraph/2)LGraph is a labeled graph of term terms.