All Projects → rstudio → graphframes

rstudio / graphframes

Licence: Apache-2.0 license
R Interface for GraphFrames

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to graphframes

sparklygraphs
Old repo for R interface for GraphFrames
Stars: ✭ 13 (-63.89%)
Mutual labels:  sparklyr, graphframes
nxontology
NetworkX-based Python library for representing ontologies
Stars: ✭ 45 (+25%)
Mutual labels:  graphs
SuiteSparseGraphBLAS.jl
Sparse, General Linear Algebra for Graphs!
Stars: ✭ 79 (+119.44%)
Mutual labels:  graphs
SeaPearl.jl
Julia hybrid constraint programming solver enhanced by a reinforcement learning driven search.
Stars: ✭ 119 (+230.56%)
Mutual labels:  graphs
ragedb
In Memory Property Graph Server using a Shared Nothing design
Stars: ✭ 75 (+108.33%)
Mutual labels:  graphs
CondGen
Conditional Structure Generation through Graph Variational Generative Adversarial Nets, NeurIPS 2019.
Stars: ✭ 46 (+27.78%)
Mutual labels:  graphs
arcdiagram
R package arcdiagram
Stars: ✭ 75 (+108.33%)
Mutual labels:  graphs
chartjs-chart-graph
Chart.js Graph-like Charts (tree, force directed)
Stars: ✭ 103 (+186.11%)
Mutual labels:  graphs
Erdos.jl
A library for graph analysis written Julia.
Stars: ✭ 37 (+2.78%)
Mutual labels:  graphs
mully
R package to create, modify and visualize graphs with multiple layers.
Stars: ✭ 36 (+0%)
Mutual labels:  graphs
SurrealNumbers.jl
Implementation of Conway's Surreal Numbers
Stars: ✭ 30 (-16.67%)
Mutual labels:  graphs
football-graphs
Graphs and passing networks in football.
Stars: ✭ 81 (+125%)
Mutual labels:  graphs
Leetcode-solutions
Leetcode Grinder.
Stars: ✭ 14 (-61.11%)
Mutual labels:  graphs
pyspark-algorithms
PySpark Algorithms Book: https://www.amazon.com/dp/B07X4B2218/ref=sr_1_2
Stars: ✭ 72 (+100%)
Mutual labels:  graphframes
grandiso-networkx
Performant, pure-Python subgraph isomorphism and monomorphism search (aka "motif search")
Stars: ✭ 30 (-16.67%)
Mutual labels:  graphs
sparklines
Text-based sparkline command line mimicking those of Edward Tuft.
Stars: ✭ 84 (+133.33%)
Mutual labels:  graphs
jgrapht
Master repository for the JGraphT project
Stars: ✭ 2,259 (+6175%)
Mutual labels:  graphs
asyncmachine
Relational State Machine with a visual inspector
Stars: ✭ 67 (+86.11%)
Mutual labels:  graphs
deep-hyperedges
New Algorithms for Learning on Hypergraphs
Stars: ✭ 21 (-41.67%)
Mutual labels:  graphs
PageRank
Page Rank library for Javascript
Stars: ✭ 23 (-36.11%)
Mutual labels:  pagerank

R interface for GraphFrames

Build Status Coverage status CRAN status

Installation

For those already using sparklyr simply run:

install.packages("graphframes")
# or, for the development version,
# devtools::install_github("rstudio/graphframes")

Otherwise, install first sparklyr from CRAN using:

install.packages("sparklyr")

The examples make use of the highschool dataset from the ggplot package.

Getting Started

We will calculate PageRank over the built-in “friends” dataset as follows.

library(graphframes)
library(sparklyr)
library(dplyr)

# connect to spark using sparklyr
sc <- spark_connect(master = "local", version = "2.3.0")

# obtain the example graph
g <- gf_friends(sc)

# compute PageRank
results <- gf_pagerank(g, tol = 0.01, reset_probability = 0.15)
results
## GraphFrame
## Vertices:
##   $ id       <chr> "f", "b", "g", "a", "d", "c", "e"
##   $ name     <chr> "Fanny", "Bob", "Gabby", "Alice", "David", "Charlie",...
##   $ age      <int> 36, 36, 60, 34, 29, 30, 32
##   $ pagerank <dbl> 0.3283607, 2.6555078, 0.1799821, 0.4491063, 0.3283607...
## Edges:
##   $ src          <chr> "b", "c", "d", "e", "a", "a", "e", "f"
##   $ dst          <chr> "c", "b", "a", "f", "e", "b", "d", "c"
##   $ relationship <chr> "follow", "follow", "friend", "follow", "friend",...
##   $ weight       <dbl> 1.0, 1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 1.0

We can then visualize the results by collecting the results to R:

library(tidygraph)
library(ggraph)

vertices <- results %>%
  gf_vertices() %>%
  collect()

edges <- results %>%
  gf_edges() %>%
  collect()

edges %>%
  as_tbl_graph() %>%
  activate(nodes) %>%
  left_join(vertices, by = c(name = "id")) %>%
  ggraph(layout = "nicely") +
  geom_node_label(aes(label = name.y, color = pagerank)) +
  geom_edge_link(
    aes(
      alpha = weight,
      start_cap = label_rect(node1.name.y),
      end_cap = label_rect(node2.name.y)
    ),
    arrow = arrow(length = unit(4, "mm"))
  ) +
  theme_graph(fg_text_colour = 'white')

Further Reading

Appart from calculating PageRank using gf_pagerank, many other functions are available, including:

  • gf_bfs(): Breadth-first search (BFS).
  • gf_connected_components(): Connected components.
  • gf_shortest_paths(): Shortest paths algorithm.
  • gf_scc(): Strongly connected components.
  • gf_triangle_count(): Computes the number of triangles passing through each vertex and others.
  • gf_degrees(): Degrees of vertices

For instance, one can calculate the degrees of vertices using gf_degrees as follows:

gf_friends(sc) %>% gf_degrees()
## # Source: spark<?> [?? x 2]
##   id    degree
## * <chr>  <int>
## 1 f          2
## 2 b          3
## 3 a          3
## 4 c          3
## 5 e          3
## 6 d          2

Finally, we disconnect from Spark:

spark_disconnect(sc)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].