Coder Social home page Coder Social logo

schochastics / edgebundle Goto Github PK

View Code? Open in Web Editor NEW
122.0 122.0 10.0 15.4 MB

R package implementing edge bundling algorithms

Home Page: https://schochastics.github.io/edgebundle/

License: Other

R 65.01% C++ 34.99%
graph-algorithms network-analysis rstats visualization

edgebundle's Introduction

 Hi, I'm David! 👋 



I am the Team Lead for "Transparent Social Anlytics" in the Department for Computational Social Science at GESIS

My main dev work is writing R packages and extensions for Quarto


Quarto

Academicons Shortcodes to use academicons with Quarto
Devicons Shortcodes to use devicons with Quarto
Blackboard revealjs theme A blackboard style theme for revealjs
Sketchy HTML theme A sketchy theme for HTML documents
Social Share Buttons Add social share buttons to HTML documents
Nutshell Include expandable explanations in documents
Quartocities Geocities template for Quarto websites
Glossary with nutshell Automatic glossary for websites using nutshell
CV templates CV/Resume templates for Quarto

edgebundle's People

Contributors

schochastics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

edgebundle's Issues

Error: datashader.bundling

Thanks for the package. The maps look awesome.

I am having a problem running the code provided on the website. Specifically I am struggling to run the following line:

hbundle <- edge_bundle_hammer(g, xy, bw = 0.7, decay = 0.5)

It returns this error:
Error: Python module datashader.bundling was not found.

I checked I have this datashader installed and it is:

(flowmap) MacBook-Pro-5:flow-map_edgebundle franciscorowe$ conda list
# packages in environment at /Users/franciscorowe/opt/anaconda3/envs/flowmap:
#
# Name                    Version                   Build  Channel
brotli                    1.0.9                    pypi_0    pypi
brotli-python             1.0.9           py311h814d153_9    conda-forge
bzip2                     1.0.8                h0d85af4_4    conda-forge
ca-certificates           2023.7.22            h8857fd0_0    conda-forge
certifi                   2023.7.22          pyhd8ed1ab_0    conda-forge
charset-normalizer        3.2.0              pyhd8ed1ab_0    conda-forge
click                     8.1.6           unix_pyh707e725_0    conda-forge
cloudpickle               2.2.1              pyhd8ed1ab_0    conda-forge
colorcet                  3.0.1              pyhd8ed1ab_0    conda-forge
dask-core                 2023.8.0           pyhd8ed1ab_0    conda-forge
**datashader**               0.15.2             pyhd8ed1ab_0    conda-forge
....

Yet, I get the same error when I run the line of code above.

Any advice on this issue would be appreciated, or general advice on how to get the package working.

My computational set up is:

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

Problems with hammer_bundle

Hi,

First of all, thanks for the great package - stunning viz.

I am trying to replicate the example here, and I am hitting an error running this line:
hbundle <- edge_bundle_hammer(g,xy,bw = 0.7,decay = 0.5)

The error message is:
Error in py_call_impl(callable, dots$args, dots$keywords) : ImportError: hammer_bundle operation requires scikit-image. Ensure you install the dependency before applying bundling.

I thought there was a compatibility issue with scikit-image so I installed a older version scikit-image-0.17.2. However, I keep getting the same issue.

Any ideas on how to resolve the issue?

I am using:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  10.16

Can edgebundle be exported as a shapefile?

First of all, I would like to thank you so much for creating this package. I have been waiting (and trying solutions on my own) for edge bundling in R for a while and this really saves my life!

I would like to know if edgebundle can be exported as line shapefiles, or converted to line shapefiles in some ways. I suppose that the group column in fbundle file indicates which line the points should sit in. If so, if I convert all the points under the same group as lines (probably through sf package), can the result be an exported shapefile? What does the index column mean in fbundle dataframe? The reason why I want a shapefile is because I have been using tmap for base map mapping and it is not compatible with ggplot syntax. I would like to use this package to process the data into edgebundles and then plot it using tmap.

Reproduce maps from your code using fbundle
Screen Shot 2020-12-20 at 4 33 37 PM

Here is my first trial of trying to convert fbundle to dataframe and plot with tmap that can directly plot shapefile (see codes below). The output seems decently similar to the fbundle in ggplot, but still have some differences that I do not know what went wrong.
Screen Shot 2020-12-20 at 4 37 48 PM

library(tmap)
library(ggraph)
library(tidyverse)
library(igraph)
library(sf)
library(edgebundle)

g <- us_flights
xy <- cbind(V(g)$longitude,V(g)$latitude)
verts <- data.frame(x=V(g)$longitude,y=V(g)$latitude)

fbundle <- edge_bundle_force(g,xy,compatibility_threshold = 0.6)

#trying to convert fbundle dataframe to a shapefile#
test = fbundle %>% st_as_sf(coords=c('x', 'y'), crs=4326) %>%
  group_by(group) %>% summarise(index=sum(index)) %>% st_cast("LINESTRING")

tm_shape(test) +
  tm_lines(col='black', lwd=0.1)

Many thanks.
Xiaofan

Error during the installation

Hello mr. David, I'm not able to install your package because this error appears:

library(remotes) 
remotes::install_github("schochastics/edgebundle")
Downloading GitHub repo schochastics/edgebundle@HEAD
✓  checking for file ‘/private/var/folders/nz/cn8n1fgn7y3_t96jpvxplh6c0000gn/T/RtmplmTYGd/remotesa5d59b6e4ef/schochastics-edgebundle-5ee713a/DESCRIPTION’ (404ms)
─  preparing ‘edgebundle’:
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘edgebundle/man/figures’
─  building ‘edgebundle_0.1.0.9000.tar.gz’
   
* installing *source* package ‘edgebundle’ ...
** using staged installation
** libs
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data' [-Wunused-variable]
            SEXP data = Parent::get__();
                 ^
1 warning generated.
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include   -fPIC  -Wall -g -O2  -c forceBundle.cpp -o forceBundle.o
In file included from forceBundle.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:57:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/DataFrame.h:136:18: warning: unused variable 'data' [-Wunused-variable]
            SEXP data = Parent::get__();
                 ^
forceBundle.cpp:28:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector vec = {P[2] - P[0],P[3] - P[1]};
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~
forceBundle.cpp:44:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector vec = {(Q_source_x + r * (Q_target_x - Q_source_x)),
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forceBundle.cpp:54:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector qs = {Q[0],Q[1]};//Q[inds];
                ^    ~~~~~~~~~~~
forceBundle.cpp:55:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector qt = {Q[2],Q[3]};//Q[indt];
                ^    ~~~~~~~~~~~
forceBundle.cpp:60:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector midI = {(I0[0] + I1[0]) / 2.0,
                ^      ~~~~~~~~~~~~~~~~~~~~~~~
forceBundle.cpp:62:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector midP = {(P[0] + P[2]) / 2.0,
                ^      ~~~~~~~~~~~~~~~~~~~~~
forceBundle.cpp:135:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_source =  {P[0],P[1]};//P[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:136:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_target =  {P[2],P[3]};//P[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:137:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_source =  {Q[0],Q[1]};//Q[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:138:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_target =  {Q[2],Q[3]};//Q[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:151:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_source =  {P[0],P[1]};//P[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:152:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_target =  {P[2],P[3]};//P[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:153:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_source =  {Q[0],Q[1]};//Q[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:154:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_target =  {Q[2],Q[3]};//Q[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:169:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_source =  {P[0],P[1]};//P[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:170:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector P_target =  {P[2],P[3]};//P[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:171:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_source =  {Q[0],Q[1]};//Q[inds];
                ^           ~~~~~~~~~~~
forceBundle.cpp:172:17: error: non-aggregate type 'Rcpp::NumericVector' (aka 'Vector<14>') cannot be initialized with an initializer list
  NumericVector Q_target =  {Q[2],Q[3]};//Q[indt];
                ^           ~~~~~~~~~~~
forceBundle.cpp:215:25: error: non-aggregate type 'Rcpp::IntegerVector' (aka 'Vector<13>') cannot be initialized with an initializer list
          IntegerVector ecomp = {oe};
                        ^       ~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [forceBundle.o] Error 1
ERROR: compilation failed for package ‘edgebundle’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/edgebundle’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/nz/cn8n1fgn7y3_t96jpvxplh6c0000gn/T//RtmplmTYGd/filea5d767034ec/edgebundle_0.1.0.9000.tar.gz’ had non-zero exit status

Can you help me in solving this problem? I apologize in advance if this is a trivial problem. I'm a beginner in R but can't wait to use this library. Thank you for your work.

Add weight to edgebundle results

Hi David!

I wonder if there is a way to add weights to the edge bundle results (e.g., fbundle, bundle etc.). The weights represent the volumes in the flow OD network, which is a common characteristic in network visualization. Ideally, I should be able to add weights to igraph object g (e.g., E(g)$weight = c(1,2,3)) and the return data frame from edgebundle will include an additional column that indicates weights by group. I assume that each group represents a line because the total number of groups and the total number of edges are consistent in your US flight example. Currently, I cannot figure out a way to match the bundled edges (or the group) to the original igraph object g, and thus cannot associate weights with the bundled edges.

Can you help with a solution?

Many thanks!
Xiaofan

Cannot install the package

Hello developer,

Excelent work! However, when I was tying to install the package, it poped out an error message, please check the error messgae below:

> remotes::install_github("schochastics/edgebundle")
Error: Failed to install 'unknown package' from GitHub:
  HTTP error 404.
  No commit found for the ref master

  Did you spell the repo owner (`schochastics`) and repo name (`edgebundle`) correctly?
  - If spelling is correct, check that you have the required permissions to access the repo.

Can you help me with this? Thank you very much.

Handling duplicates in triangulation

I have been trying to plot international trade flows from Aotearoa, New Zealand. I have ensured that there are no duplicates in nodes or edges but I still get the following error.

 Error in interp::tri.mesh(xymesh[, 1], xymesh[, 2]) : 
  duplicate data points 

In the end, I had to make the following change to tnss_tree() for the error to go away.

  #triangulate points
  tria <- interp::tri.mesh(xymesh[,1],xymesh[,2])
  tria <- interp::tri.mesh(xymesh[,1],xymesh[,2], duplicate = "remove")

I will post the code and link to the data in a blog post later this week as it is a little too long for an issue! I would love to see this change in the main package so that I can now plot flows that span the globe from little old New Zealand! Thanks for writing such a wonderful package! :-) I had been looking for something like for a long time!

image

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.