find_substr_isomorph: Finds all substructure isomorphisms

Description Usage Arguments Examples

Description

Finds all substructure isomorphisms

Usage

1
find_substr_isomorph(substr_lab, substr_ct, str_lab, str_ct)

Arguments

substr_lab
substr_ct
str_lab
str_ct

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (substr_lab, substr_ct, str_lab, str_ct) 
{
    isomorph <- function(stp) {
        for (i in 1:str_size) if (!used[i] && substr_lab[stp] == 
            str_lab[i]) {
            cc[stp] <<- i
            if (stp > 1) 
                for (j in 1:(stp - 1)) if ((substr_ct[stp, j] != 
                  0) && (substr_ct[stp, j] != str_ct[i, cc[j]])) {
                  to_exit <- TRUE
                  next
                }
            if (to_exit) {
                to_exit <- FALSE
                next
            }
            if (stp == substr_size) {
                num_matches <<- num_matches + 1
                isom_list[[num_matches]] <<- cc
            }
            else {
                used[i] <<- TRUE
                isomorph(stp + 1)
                used[i] <<- FALSE
            }
        }
    }
    substr_size <- length(substr_lab)
    str_size <- length(str_lab)
    used <- logical(str_size)
    cc <- integer(substr_size)
    to_exit <- FALSE
    num_matches <- 0
    isom_list <- list()
    isomorph(1)
    isom_list
  }

conmolfields documentation built on May 2, 2019, 4:18 p.m.