Description Usage Arguments Examples
Directs the edges between a pair of clusters. There are 3 options when an abstraction is added: 1) there is no directed edge in the abstraction. This means both directions must be tried. 2) there is 1 directed edge in the abstraction. This means all edges must be pointed that way. 3) there are more than 1 directed edges in the abstraction. This means that first, it must be checked whether they all point in the same direction. Then, it must be checked if there are undirected edges left. If so, they must point in the same direction as well.
1 | add_abstraction(pdag, abs_group1, abs_group2)
|
pdag |
|
abs_group1 |
|
abs_group2 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | ##---- 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 (pdag, abs_group1, abs_group2)
{
abs_group1 <- as.numeric(noquote(gsub("[^0-9]", "", abs_group1)))
abs_group2 <- as.numeric(noquote(gsub("[^0-9]", "", abs_group2)))
dir_list <- check_directed_edges(pdag, abs_group1, abs_group2)
v_structures <- number_v_nodes(pdag)
if (length(dir_list) == 0) {
print("no directed edges found on the abstraction")
pdag1 <- change_direction(pdag, abs_group1, abs_group2)
dir1 <- is_direction_possible(pdag1, v_structures)
pdag2 <- change_direction(pdag, abs_group2, abs_group1)
dir2 <- is_direction_possible(pdag2, v_structures)
if (dir1 && dir2) {
cat("Two possible directions of the edges. Need to check for any necessary edges among them.")
end_pdag_list <- list()
col <- ncol(pdag)
row <- nrow(pdag)
for (i in 1:length(pdag)) {
if (pdag1[i] == 0 && pdag2[i] == 0) {
end_pdag_list[i] = 0
}
else {
end_pdag_list[i] = 1
}
}
end_pdag <- matrix(end_pdag_list, nrow = row, ncol = col)
return(end_pdag)
}
if (dir1 && !dir2) {
cat("The direction from abs_group1 -> abs_group2 is the only possible direction.")
pdag <- apply_mec_rules(pdag1)
return(pdag)
}
if (!dir1 && dir2) {
cat("The direction from abs_group1 <- abs_group2 is the only possible direction.")
pdag <- apply_mec_rules(pdag2)
return(pdag)
}
if (!dir1 && !dir2) {
cat("Both the direction are not possible...")
return(pdag)
}
}
else if (length(dir_list) == 2) {
print("one directed edge found. Need to convert other edges the same way.")
group1_check <- check_direction(pdag, dir_list, abs_group1)
if (!(group1_check)) {
q <- abs_group1
abs_group1 <- abs_group2
abs_group2 <- q
}
pdag <- change_direction(pdag, abs_group1, abs_group2)
pdag <- apply_mec_rules(pdag)
return(pdag)
}
else {
print("multiple directed edges found. Need to check if they match.")
leftrightlist <- list_dir_edges(dir_list)
result <- match_dir_edges(leftrightlist$left, leftrightlist$right,
abs_group1)
if (result == "error") {
cat("Error found!")
}
else if (result == "left") {
cat("the directed edges match with the pattern! Leftlist is in absgroup1.")
for (i in 1:abs_group1) {
if (!(i %in% leftrightlist$left)) {
cat("Not all edges are directed yet.")
group1_check <- check_direction(pdag, dir_list,
abs_group1)
if (!(group1_check)) {
q <- abs_group1
abs_group1 <- abs_group2
abs_group2 <- q
}
pdag <- change_direction(pdag, abs_group1,
abs_group2)
return(pdag)
}
else {
cat("all edges are already directed equally. The abstraction doesn't give extra information.")
return(pdag)
}
}
}
else if (result == "right") {
cat("the directed edges match with the pattern! Rightlist is in absgroup1.")
for (i in 1:abs_group1) {
if (!(i %in% leftrightlist$right)) {
cat("Not all edges are directed yet.")
group1_check <- check_direction(pdag, dir_list,
abs_group1)
if (!(group1_check)) {
q <- abs_group1
abs_group1 <- abs_group2
abs_group2 <- q
}
pdag <- change_direction(pdag, abs_group1,
abs_group2)
return(pdag)
}
else {
cat("all edges are already directed equally. The abstraction doesn't give extra information.")
return(pdag)
}
}
}
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.