Description

Determine the separation vertices of a graph.

Author

Richard Kelsey; ported to Chicken by Ivan Raikov

Version

Requires

Download

graph-separators.egg

Usage

(require-extension graph-separators)

Documentation

A graph is said to have a separation vertex v (sometimes called an articulation point) if there exist vertices a and b, where a != b and b != v, and all paths connecting a and b pass through v. A graph which has a separation vertex is called separable, and one which has none is called non-separable.

Procedures

procedure: graph-separation-vertices:: G -> SEPARATORS * COMPONENTS

Computes the separation vertices of the given graph. Returns a list of separation vertices and a list of graph components that contain a separation vertex.

Examples

(require-extension srfi-1)
(require-extension digraph)
(require-extension graph-separators)

(define g (make-digraph 'depgraph "dependency graph"))

(define used-by
   (list 
     (cons 'dax_h 'foo_cpp) (cons 'def_h 'foo_cpp) (cons 'xyz_h 'foo_cpp)
     (cons 'foo_cpp 'libfoobar_a ) (cons 'foo_cpp 'libzigzag_a)
     (cons 'libfoobar_a 'app) (cons 'libzigzag_a 'app)
   ))

(define node-list (delete-duplicates 
		   (concatenate (list (map car used-by) (map cdr used-by)))))

(define node-ids (list-tabulate (length node-list) values))
 
(for-each (lambda (i n) ((g 'add-node!) i (list #f n))) node-ids node-list)
(define node-map (zip node-list node-ids))

(for-each (lambda (e) 
	    (match e ((ni . nj) (let ((i (car (alist-ref ni node-map)))
				      (j (car (alist-ref nj node-map))))
				  ((g 'add-edge!) (list i j (format "~A->~A" ni nj)))))
		   (else (error "invalid edge " e))))
	  used-by)

(graph-separation-vertices g)

License

Copyright (c) 1993-1999 by Richard Kelsey.  

   Ported to Chicken Scheme by Ivan Raikov.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:
   
     1. Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.

     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

     3. The names of its contributors may not be used to endorse or promote 
        products derived from this software without specific prior written 
        permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER 
   OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.