GithubHelp home page GithubHelp logo

gi0na / adjhelpr Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 0.0 696 KB

R tools to build and deal with adjacency matrices

Home Page: http://adjhelpr.ghyper.net/

License: GNU Affero General Public License v3.0

R 100.00%
adjacency-matrices edgelists weighted-edgelists networks network-analysis social-network-analysis

adjhelpr's Introduction

adjHelpR

Travis build status

The goal of adjHelpR is to provide tools to generate adjacency matrices from weighted edgelists, create weighted edgelists from edgelists with repeated edges, and handle these objects. It exploits dplyr and tibbles to deal efficiently with large edgelists, and Matrix sparse matrices to store adjacency matrices in sparse format.

Installation

You can install the released version of adjHelpR from CRAN with:

install.packages("adjHelpR")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("gi0na/adjHelpR")

Example

This is a basic example on how to generate a weighted adjacency matrix from an edge list:

library(adjHelpR)

el <- data.frame(from= c('a','b','b','c','d','d'),
                 to  = c('b','c','d','a','b','a'),
                 attr= c( 12, 6, 12 , 6 , 6 , 6 ))
(adj <- get_adjacency(el))
#> 4 x 4 sparse Matrix of class "dgCMatrix"
#>   a  b c  d
#> a . 12 .  .
#> b .  . 6 12
#> c 6  . .  .
#> d 6  6 .  .

(el_unweighted <- tibble::as_tibble(do.call(rbind, 
                        apply(el, 1, function(row) matrix(rep(row[1:2], each=as.integer(row[3])), ncol = 2))), 
                        .name_repair='minimal'))
#> # A tibble: 48 x 2
#>    ``    ``   
#>    <chr> <chr>
#>  1 a     b    
#>  2 a     b    
#>  3 a     b    
#>  4 a     b    
#>  5 a     b    
#>  6 a     b    
#>  7 a     b    
#>  8 a     b    
#>  9 a     b    
#> 10 a     b    
#> # … with 38 more rows
(adj <- get_adjacency(el_unweighted, multiedge = TRUE))
#> 4 x 4 sparse Matrix of class "dgCMatrix"
#>   a  b c  d
#> a . 12 .  .
#> b .  . 6 12
#> c 6  . .  .
#> d 6  6 .  .

Acknowledgements

The research and development behind adjHelpR is performed at the Chair of Systems Design, ETH Zürich.

Contributors

Giona Casiraghi

Christian Zingg

Copyright

adjHelpR is licensed under the GNU Affero General Public License.

c Copyright ETH Zürich, 2019-2021

adjhelpr's People

Contributors

gi0na avatar

Stargazers

 avatar  avatar  avatar

adjhelpr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.