View source: R/graph-partitioning.R

unconnected_partition | R Documentation |

Finds an Approximately Balanced Partition

unconnected_partition( from, to, weight_data = NULL, edge_weights = NULL, slack = 0, max_kl_it_inner = 50L, max_kl_it = 10000L, trace = 0L, init = integer() ) unconnected_partition_pedigree( id, father.id, mother.id, id_weight = NULL, father_weight = NULL, mother_weight = NULL, slack = 0, max_kl_it_inner = 50L, max_kl_it = 10000L, trace = 0L, init = integer() )

`from` |
integer vector with one of the vertex ids. |

`to` |
integer vector with one of the vertex ids. |

`weight_data` |
list with two elements called |

`edge_weights` |
numeric vector with weights for each edge. Needs to have
the same length as |

`slack` |
fraction between zero and 0.5 for the allowed amount of deviation from the balance criterion that is allowed to reduce the cost of the cut edges. |

`max_kl_it_inner` |
maximum number of moves to consider in each
iteration when |

`max_kl_it` |
maximum number of iterations to use when reducing the cost of the cut edges. Typically the method converges quickly and this argument is not needed. |

`trace` |
integer where larger values yields more information printed to the console during the procedure. |

`init` |
integer vector with ids that one of the two sets in the partition should start out with. |

`id` |
integer vector with the child id. |

`father.id` |
integer vector with the father id. May be |

`mother.id` |
integer vector with the mother id. May be |

`id_weight` |
numeric vector with the weight to use for each vertex
(individual). |

`father_weight` |
weights of the edges created between the fathers
and the children. Use |

`mother_weight` |
weights of the edges created between the mothers
and the children. Use |

A list with the following elements:

`balance_criterion` |
value of the balance criterion. |

`removed_edges` |
2D integer matrix with the removed edges. |

`set_1,set_2` |
The two sets in the partition. |

`max_balanced_partition`

.

# example of a data set in pedigree and graph form library(pedmod) dat_pedigree <- data.frame( id = 1:48, mom = c( NA, NA, 2L, 2L, 2L, NA, NA, 7L, 7L, 7L, 3L, 3L, 3L, 3L, NA, 15L, 15L, 43L, 18L, NA, NA, 21L, 21L, 9L, 9L, 9L, 9L, NA, NA, 29L, 29L, 29L, 30L, 30L, NA, NA, 36L, 36L, 36L, 38L, 38L, NA, NA, 43L, 43L, 43L, 32L, 32L), dad = c(NA, NA, 1L, 1L, 1L, NA, NA, 6L, 6L, 6L, 8L, 8L, 8L, 8L, NA, 4L, 4L, 42L, 5L, NA, NA, 20L, 20L, 22L, 22L, 22L, 22L, NA, NA, 28L, 28L, 28L, 23L, 23L, NA, NA, 35L, 35L, 35L, 31L, 31L, NA, NA, 42L, 42L, 42L, 45L, 45L), sex = c(1L, 2L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L)) dat <- list( to = c( 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 16L, 17L, 18L, 19L, 22L, 23L, 24L, 25L, 26L, 27L, 30L, 31L, 32L, 33L, 34L, 37L, 38L, 39L, 40L, 41L, 44L, 45L, 46L, 47L, 48L, 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 16L, 17L, 18L, 19L, 22L, 23L, 24L, 25L, 26L, 27L, 30L, 31L, 32L, 33L, 34L, 37L, 38L, 39L, 40L, 41L, 44L, 45L, 46L, 47L, 48L), from = c( 1L, 1L, 1L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 4L, 4L, 42L, 5L, 20L, 20L, 22L, 22L, 22L, 22L, 28L, 28L, 28L, 23L, 23L, 35L, 35L, 35L, 31L, 31L, 42L, 42L, 42L, 45L, 45L, 2L, 2L, 2L, 7L, 7L, 7L, 3L, 3L, 3L, 3L, 15L, 15L, 43L, 18L, 21L, 21L, 9L, 9L, 9L, 9L, 29L, 29L, 29L, 30L, 30L, 36L, 36L, 36L, 38L, 38L, 43L, 43L, 43L, 32L, 32L)) # the results may be different because of different orders! out_pedigree <- unconnected_partition_pedigree( id = dat_pedigree$id, father.id = dat_pedigree$dad, mother.id = dat_pedigree$mom) out <- unconnected_partition(dat$to, dat$from) all.equal(out_pedigree$balance_criterion, out$balance_criterion) all.equal(out_pedigree$removed_edges, out$removed_edges)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.