Skip to content
Snippets Groups Projects
Select Git revision
  • eb7be7f2ef084248b2a9af4d58fed5274c2ea1b6
  • main default protected
  • beta_release protected
  • feature/RWTH_CPACS_Interface
  • feature_CPACS_Interface
  • feature/design_evaluator
  • XMLEditor
  • electron-app-file-loading
  • testing
  • UnicadoGUI
  • UnicadoGuiFrontend
  • settingsPage
  • projektexplorer
  • UnicadoGuiBackend
  • v0.6.0
  • 0.5.0
  • 0.4.0
  • 0.3.0
  • 0.2.0
  • 0.1.0
20 results

projects.js

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    binarise_graph_prop.R 1.31 KiB
    #' Remove all connections that are not in the proportion of strongest edges
    #'
    #' Graph data is limited to connections at are in the proportion above the
    #' specified threshold. Thus, specifying a threshold of 0.2 will filter out
    #' the weakest 20% of connections.
    #'
    #' @param graph The graph to work on.
    #' @param col The column in the edges that contains the weight.
    #' @param threshold The proportional threshold to filter at.
    #'
    #' @return The graph with weights removed, containing only edges meeting
    #' the threshold.
    #'
    #' @rdname binarise_graph_prop
    #' @export
    binarise_graph_prop <- function(graph, col, threshold) {
        csym <- rlang::enquo(col)
        abs_sym <- rlang::sym("abs_col")
        pr_sym <- rlang::sym("pr")
    
        graph_binary <- graph %>%
            tidygraph::activate("edges") %>%
            dplyr::mutate({{ abs_sym }} := abs({{ csym }})) %>%
            dplyr::mutate({{ pr_sym }} := dplyr::percent_rank({{ abs_sym }})) %>%
            dplyr::mutate(dplyr::across(
                {{ pr_sym }}, function(x) ifelse({{ abs_sym }} == 1, 0, x))) %>%
            dplyr::filter({{ pr_sym }} >= threshold) %>%
            dplyr::select(-{{ abs_sym }}, -{{ pr_sym }}, -{{ csym }})
    
        graph_binary
    }
    
    #' @rdname binarise_graph_prop
    #' @export
    binarize_graph_prop <- function(graph, col, threshold) {
        binarise_graph_prop(graph, {{ col }}, threshold)
    }