Skip to content

Commit

Permalink
docs: Polish installation & show example
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolepore committed Feb 21, 2025
1 parent 77dfd82 commit 888f68d
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 44 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ src/rust/vendor/
docs
.vscode
src/rust/vendor

/.quarto/
README.html
118 changes: 118 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# orbweaver <a><img src="https://storage.googleapis.com/ix-paquetes-internos/logo-orbweaver.png" align="right" width="30%"></a>

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/orbweaver)](https://cran.r-project.org/package=orbweaver)
[![R-CMD-check](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml/badge.svg)](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml)
<!-- badges: end -->

## Overview

A fast R library for working with Nodes in a graph.

## Features

- Find shortest paths between nodes in a graph
- Find the common parents between selected nodes
- Directed Graph
- Directed Acyclic Graph
- It is quite fast

## Why not igraph?

[igraph](https://igraph.org/) is an amazing network analysis package.
igraph is much more mature and orbweaver focuses on extreme performance
and low latency operations. If you need super high performance
and do not require weighted graphs, orbweaver may be for you.

![igraph vs orbweaver benchmark](man/figures/benchmark.png)

> We may add weighted graph in the future but for not
> it is not in the short-term road map.
## Installation

### Rust Toolchain

Before installing this package, you will need to install the
Rust toolchain.

#### Mac or Linux

If you are on Mac or Linux, you can do this
by running the following command in your terminal:

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

#### Windows

If you are on Windows, you can download the installer from
[here](https://www.rust-lang.org/tools/install).

In order to compile this package manually, you will need the
**GNU ABI** used by the **GCC toolchain**. This is not the
default on Windows, so you will need to install the
toolchain manually. You can do this by running the following
command in your terminal:

```bash
rustup toolchain install stable-gnu
```

If you are on Windows you may need to install `Rtools` as
well. You can download the installer from
[here](https://cran.r-project.org/bin/windows/Rtools/).

### R Package

Once you have the Rust toolchain installed, you can install
orbweaver from GitHub with:

```R
# install.packages("remotes")
remotes::install_github("ixpantia/orbweaver-r")
```

## Example

```{r}
library(orbweaver)
edges <- data.frame(
parent = c("A", "B", "C", "C", "F"),
child = c("B", "C", "D", "E", "D")
)
edges
graph_builder()
graph <- graph_builder() |>
populate_edges(edges, "parent", "child") |>
build_directed()
graph
str(graph)
graph |> find_all_paths(from = "A", to = "D")
# Not the other way around
graph |> find_all_paths(from = "D", to = "A")
```

120 changes: 76 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# orbweaver <a><img src="https://storage.googleapis.com/ix-paquetes-internos/logo-orbweaver.png" align="right" width="30%"></a>

<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/orbweaver)](https://cran.r-project.org/package=orbweaver)

[![CRAN
status](https://www.r-pkg.org/badges/version/orbweaver)](https://cran.r-project.org/package=orbweaver)
[![R-CMD-check](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml/badge.svg)](https://github.com/ixpantia/orbweaver/actions/workflows/check-full.yaml)
<!-- badges: end -->

Expand All @@ -12,33 +16,42 @@ A fast R library for working with Nodes in a graph.

## Features

- Find shortest paths between nodes in a graph
- Find the common parents between selected nodes
- Directed Graph
- Directed Acyclic Graph
- It is quite fast
- Find shortest paths between nodes in a graph
- Find the common parents between selected nodes
- Directed Graph
- Directed Acyclic Graph
- It is quite fast

## Why not igraph?

[igraph](https://igraph.org/) is an amazing network analysis package.
igraph is much more mature and orbweaver focuses on extreme performance
and low latency operations. If you need super high performance
and do not require weighted graphs, orbweaver may be for you.
and low latency operations. If you need super high performance and do
not require weighted graphs, orbweaver may be for you.

![igraph vs orbweaver benchmark](man/figures/benchmark.png)
<figure>
<img src="man/figures/benchmark.png"
alt="igraph vs orbweaver benchmark" />
<figcaption aria-hidden="true">igraph vs orbweaver
benchmark</figcaption>
</figure>

> We may add weighted graph in the future but for not
> it is not in the short-term road map.
> We may add weighted graph in the future but for not it is not in the
> short-term road map.
## Installation

### Rust Toolchain

Before installing this package, you will need to install the
Rust toolchain. If you are on Mac or Linux, you can do this
by running the following command in your terminal:
Before installing this package, you will need to install the Rust
toolchain.

```bash
#### Mac or Linux

If you are on Mac or Linux, you can do this by running the following
command in your terminal:

``` bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Expand All @@ -47,45 +60,64 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
If you are on Windows, you can download the installer from
[here](https://www.rust-lang.org/tools/install).

In order to compile this package manually, you will need the
**GNU ABI** used by the **GCC toolchain**. This is not the
default on Windows, so you will need to install the
toolchain manually. You can do this by running the following
command in your terminal:
In order to compile this package manually, you will need the **GNU ABI**
used by the **GCC toolchain**. This is not the default on Windows, so
you will need to install the toolchain manually. You can do this by
running the following command in your terminal:

```bash
``` bash
rustup toolchain install stable-gnu
```

If you are on Windows you may need to install `Rtools` as
well. You can download the installer from
If you are on Windows you may need to install `Rtools` as well. You can
download the installer from
[here](https://cran.r-project.org/bin/windows/Rtools/).

### R Package

Once you have the Rust toolchain installed, you can install
this package from Git using whatever method you prefer.

With `remotes`:
Once you have the Rust toolchain installed, you can install orbweaver
from GitHub with:

```R
``` r
# install.packages("remotes")
remotes::install_github("ixpantia/orbweaver-r")
```

With `devtools`:

```R
devtools::install_github("ixpantia/orbweaver-r")
```

With `renv`:

```R
renv::install("ixpantia/orbweaver-r")
```

With `pak`:

```R
pak::pak("ixpantia/orbweaver-r")
## Example

``` r
library(orbweaver)

edges <- data.frame(
parent = c("A", "B", "C", "C", "F"),
child = c("B", "C", "D", "E", "D")
)
edges
#> parent child
#> 1 A B
#> 2 B C
#> 3 C D
#> 4 C E
#> 5 F D

graph_builder()
#> <pointer: 0x60b8e1cd1790>
#> attr(,"class")
#> [1] "DirectedGraphBuilder"

graph <- graph_builder() |>
populate_edges(edges, "parent", "child") |>
build_directed()

graph

str(graph)
#> Class 'DirectedGraph' <externalptr>

graph |> find_all_paths(from = "A", to = "D")
#> [[1]]

# Not the other way around
graph |> find_all_paths(from = "D", to = "A")
#> list()
```

0 comments on commit 888f68d

Please sign in to comment.