Graphcoloring
Graph Coloring Algorithms for tidygraph
Install / Use
/learn @saurfang/GraphcoloringREADME
graphcoloring
graphcoloring is a collection of graph coloring algorithms for
coloring vertices of a graph such that no two adjacent vertices share
the same color. The algorithms are included via the embedded
‘GraphColoring’ C++ library,
https://github.com/brrcrites/GraphColoring.
Installation
You can install the released version of graphcoloring from CRAN with:
install.packages("graphcoloring")
Development version can be installed with
devtools::install_github("saurfang/graphcoloring")
Example
color_* functions operate under tidygraph family and can be used to
color nodes within mutate context similar to group_* functions in
tidygraph.
library(graphcoloring)
library(tidygraph)
library(ggraph)
set.seed(42)
play_islands(5, 10, 0.8, 3) %>%
mutate(color = as.factor(color_dsatur())) %>%
ggraph(., layout = 'kk') +
geom_edge_link(aes(alpha = ..index..), show.legend = FALSE) +
geom_node_point(aes(color = color), size = 7) +
theme_graph()
<img src="man/figures/README-example-1.png" width="100%" />
graph_coloring_* functions directly take adjacency lists and returns
an integer vector of assigned labels. For example, this can be used with
sf::st_intersects() to color a feature collection for visualization.
library(graphcoloring)
library(USAboundaries)
library(sf)
library(ggplot2)
set.seed(48)
us_states() %>%
filter(!(name %in% c("Alaska", "District of Columbia", "Hawaii", "Puerto Rico"))) %>%
mutate(
color = st_intersects(.) %>%
graph_coloring_dsatur() %>%
as.factor()
) %>%
ggplot() +
geom_sf(aes(fill = color)) +
theme_bw()
<img src="man/figures/README-sf-example-1.png" width="100%" />Related Skills
node-connect
348.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
