Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

cmu-lib/simplygraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

simplygraph provides functions to simplify graph topologies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages