SchemeExt:Graph:negate

From DocR21

Jump to: navigation, search

Contents

Action

Negates an ordered graph.

Filename

scm/scmext/kern/graph_scm.cpp

APIs

None

Syntax

(graph:negate in-graph)

Argument Types

Argument Scheme Data Type
in-graph graph

Returns

graph

Description

For noncyclic ordered graphs, the highest numbered vertices are assigned 0 and new numbering for the vertices commences from there. For cyclic ordered graphs, the 0 vertex remains the same, but sequence or direction around the cycle changes.

Arguments

  • in-graph specifies a graph.

Example

; graph:negate
; Create a simple graph.
(define g1 (graph "a-b b-c c-e c-d c-f f-g f-h"))
;; g1
(graph:order-from g1 "a")
;; 4
(graph:show-order g1)
;; ("a 0" "b 1" "c 2" "e 3" "d 3" "f 3" "g 4" "h 4")
(define g2 (graph:negate g1))
;; g2
(graph:show-order g2)
;; ("a 4" "b 3" "c 2" "e 1" "d 1" "f 1" "g 0" "h 0")
; Create a simple cyclic example
(define g3 (graph "me-you you-us us-them them-they me-they"))
;; g3
; CAREFUL: The order of the graph output may not be the same each time.
(graph:cycle? g3)
;; #t
(graph:order-cyclic g3 "me" "you")
;; 4
(graph:show-order g3)
;; ("me 0" "you 4" "us 3" "them 2" "they 1")
(define g4 (graph:negate g3))
;; g4
(graph:show-order g4)
;; ("me 0" "you 1" "us 2" "them 3" "they 4")
Personal tools
Live