knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = FALSE )
library(Rchitecture) library(purrr) library(dplyr) library(stringr)
folder <- system.file("example_data/Zeeguu-Ecosystem/Zeeguu-API/zeeguu_core", package = "Rchitecture") files <- list.files(folder, recursive = TRUE, full.names = TRUE) %>% stringr::str_extract(".*\\.py$") %>% na.omit() edges <- map(files, import_from) edge_table <- map_df(edges, transpose) node_table <- tibble::tibble( id = unique(c(edge_table$to, edge_table$from)), label= str_remove(id, paste0(folder, "/")), folder = folder, subfolder = str_remove(label, "[^/]+$") ) %>% mutate_at(vars(-id), ~str_replace_all(.x, "/+", "/") )
library(tidygraph) graph <- tbl_graph( nodes = node_table, edges = edge_table ) %>% activate("nodes") %>% mutate(graph_component = group_components()) # numeric for connected components
library(ggraph) ggraph(graph, layout = "igraph", algorithm = "fr") + geom_edge_diagonal() + geom_node_point(aes(color = subfolder)) + scale_color_brewer(type = "qual") + theme_void()
subgraphs that have imports across subfolders of zeeguu core.
as_tibble(graph) %>% group_by(graph_component) %>% summarise(n_distinct(subfolder))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.