chickadee » graph-separators

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

graph-separators

Determine the separation vertices of a graph.

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

graph-separation-vertices:procedure

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)

About this egg

Author

Richard Kelsey; ported to Chicken by Ivan Raikov

Version history

1.4
Documentation converted to wiki format
1.3
Ported to Chicken 4
1.0
Initial release

License

Copyright by Richard Kelsey.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

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

- Neither name of the copyright holders nor the names of its
contributors may 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 THE
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 HOLDERS OR THE
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.

Contents »