Action:
|
Returns whether or not a graph with a given edge is of the specified kind.
|
|
Filename:
|
kern/kern_scm/graph_scm.cxx
|
|
Syntax:
|
(graph:kind? in-graph kind item1 [item2])
|
|
Arg Types:
|
in-graph
|
graph
|
|
kind
|
integer
|
|
item1
|
string | entity
|
|
item2
|
entity
|
|
Returns:
|
boolean
|
|
Description:
|
A graph can have any number of
kind types assigned to edges of the graph.
kind is a integer for the type and can take a Boolean value. If not specified, it is assumed to be
#f. The assignment of
kind and its value is done on a per edge basis.
|
|
|
This Scheme extension provides flexibility for the types of arguments and how they are used.
|
|
|
in-graph specifies a graph.
|
|
|
kind is an integer representing a type that was assigned to a graph edge.
|
|
|
item1 argument can be either a string or an entity. When it is a string, it is tested to see whether it represents the name of an edge in the graph or a vertex in the graph.
|
|
|
item2 argument is only used when
item1 is an entity representing a vertex, in which case
item2 must also be an entity representing a vertex.
|
|
Example:
|
; graph:kind?
|
|
; Create some simple graphs.
|
|
(define g (graph "a-b b-c c-d c-e"))
|
|
;; g
|
|
(graph:set-kind g 3 #t "a-b")
|
|
;; #[graph "a-b b-c c-d c-e"]
|
|
(graph:set-kind g 3 #t "b-c")
|
|
;; #[graph "a-b b-c c-d c-e"]
|
|
(graph:kind? g 3 "a-b")
|
|
;; #t
|
|
(graph:kind? g 2 "a-b")
|
|
;; #f
|
|
(graph:kind? g 3 "b-c")
|
|
;; #t
|
|
(graph:kind? g 3 "c-e")
|
|
;; #f
|
|
|
; Create an example using entities.
|
|
(define e1 (edge:linear (position 10 10 0)
|
|
|
(position 10 -10 0)))
|
|
;; e1
|
|
(define e2 (edge:linear (position 10 -10 0)
|
|
|
(position -10 -10 0)))
|
|
;; e2
|
|
(define e3 (edge:linear (position -10 -10 0)
|
|
|
(position -10 10 0)))
|
|
;; e3
|
|
(define e4 (edge:linear (position -10 10 0)
|
|
|
(position 10 10 0)))
|
|
;; e4
|
|
(define g1 (graph (list e1 e2 e3 e4)))
|
|
;; g1
|
|
(define ve (graph:vertex-entities g1))
|
|
;; ve
|
|
(graph:set-kind g1 0 #t
|
|
|
(list-ref ve 0) (list-ref ve 1))
|
|
;; #[graph "(entity 10 65536)-(entity 11 65536)
|
|
;; (entity 12 65536)-(entity 13 65536)
|
|
;; (entity 6 65536)-(entity 7 65536)
|
|
;; (entity 8 65536)-(entity 9 65536)"]
|
|
(graph:set-kind g1 1 #t
|
|
|
(list-ref ve 2) (list-ref ve 3))
|
|
;; #[graph "(entity 10 65536)-(entity 11 65536)
|
|
;; (entity 12 65536)-(entity 13 65536)
|
|
;; (entity 6 65536)-(entity 7 65536)
|
|
;; (entity 8 65536)-(entity 9 65536)"]
|
|
(graph:set-kind g1 2 #t
|
|
|
(list-ref ve 4) (list-ref ve 5))
|
|
;; #[graph "(entity 10 65536)-(entity 11 65536)
|
|
;; (entity 12 65536)-(entity 13 65536)
|
|
;; (entity 6 65536)-(entity 7 65536)
|
|
;; (entity 8 65536)-(entity 9 65536)"]
|
|
(graph:kind? g1 0 (list-ref ve 0) (list-ref ve 1))
|
|
;; #t
|
|
(graph:kind? g1 1 (list-ref ve 0) (list-ref ve 1))
|
|
;; #f
|
|
(graph:kind? g1 2 (list-ref ve 0) (list-ref ve 1))
|
|
;; #f
|
|
(graph:kind? g1 0 (list-ref ve 2) (list-ref ve 3))
|
|
;; #f
|
|
(graph:kind? g1 1 (list-ref ve 2) (list-ref ve 3))
|
|
;; #t
|
|
(graph:kind? g1 2 (list-ref ve 2) (list-ref ve 3))
|
|
;; #f
|
|
(graph:kind? g1 0 (list-ref ve 4) (list-ref ve 5))
|
|
;; #f
|
|
(graph:kind? g1 1 (list-ref ve 4) (list-ref ve 5))
|
|
;; #f
|
|
(graph:kind? g1 2 (list-ref ve 4) (list-ref ve 5))
|
|
;; #t
|