knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
simplygraph provides functions to simplify graph topologies.
You can install the development version of simplygraph from GitHub with:
# install.packages("devtools") devtools::install_github("cmu-lib/simplygraph")
Say you have a graph where multiple nodes could be removed while still maintaining the same intersections between paths:
set.seed(100) library(igraph) library(simplygraph) graph <- igraph::graph_from_edgelist( matrix(c( "a", "b", "b", "f", "b", "d", "d", "c", "d", "e", "e", "k", "j", "k", "f", "g", "c", "h", "h", "i", "f", "j" ), ncol = 2, byrow = TRUE), directed = FALSE ) plot(graph)
Nodes j
, k
, e
, c
, and h
could be removed without fundamentally altering the relationship of path intersections in this graph. simplify_topology()
finds those 2-degree nodes and removes them, rewiring the remaining tangent nodes.
simple_graph <- simplify_topology(graph) plot(simple_graph)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.