README.md

simplygraph

simplygraph provides functions to simplify graph topologies.

Installation

You can install the development version of simplygraph from GitHub with:

# install.packages("devtools")
devtools::install_github("cmu-lib/simplygraph")

Example

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)



cmu-lib/simplygraph documentation built on Nov. 4, 2019, 9:09 a.m.