Questions tagged [tidygraph]

Tidygraph provides a tidy framework in R for all things relational (networks/graphs, trees, etc.). It is often used alongside ggraph.

102 questions
2
votes
1 answer

How to hide unconnected nodes in ggraph

Given the following example code, library(tidyverse) library(tidygraph) library(ggraph) reprex <- tibble(to = 1:10, from = c(2:10, 1), facet = rep(1:2, each = 5)) %>% as_tbl_graph() reprex_plot <- reprex…
martijn
  • 43
  • 7
1
vote
1 answer

Calculate degree for subgraphs with tidygraph

my problem is the following. I have a network with multiple layers (based on edge attributes), like year in the highschool network. I would like to store node degree for each layer as a separate node attribute, to use it in visualisation. While…
1
vote
1 answer

Network/tree data: calculate number of independent trees and average maximum edges per independent tree

I would like to draw network plots using tidygraph and ggraph. I have a larger tibble with items connected via from and to. Some of the trees are connected (a0 and b0 in the example). I would like to: Count the number of independent trees Calculate…
ava
  • 840
  • 5
  • 19
1
vote
1 answer

Small multiples plots replicating entire network in each panel in ggraph()

I would like to make a small multiples plot of a network using ggraph. For each node in my network, I have two features, feat1 and feat2. I would like to visualize the feat1 for the entire network in one panel, and feat2 for the entire network in…
alexpghayes
  • 673
  • 5
  • 17
1
vote
1 answer

ggraph transpose graph coordinates

I have a tree diagram which I want to display horizontally. I had been using igraph and inspiration from this solution, but I am updating my code to {ggraph} hoping for a cleaner aesthetic and better control over edge labels. In {igraph} I am able…
M. Wood
  • 450
  • 4
  • 13
1
vote
1 answer

Mutate functions on the neighborhood of a node in Tidygraph without a map

I have a graph, with an attribute W. I want to mutate the average W of the neighbors. I want to keep the code as simple as possible, trying to avoid maps and other explicit functions for vectorisation, because this is for didactic purposes. My code,…
GiulioGCantone
  • 195
  • 1
  • 10
1
vote
2 answers

Graph learning in R, igraph, tidygraph

I have a graph with each node having a value (value in red). I would like to do the following two things (I guess 1 is a special case of 2): Each node should be assigned the mean of the value of the direct peers directing to it. For example node…
Martin
  • 1,141
  • 14
  • 24
1
vote
1 answer

How to plot a single node using tidygraph objects in R?

I was wondering if it is possible to plot a tidygraph object with a single node? For example, if I create some data and a tidygraph object with 2 nodes, that would look like this: library(tidygraph) library(graph) nodes <- data.frame(name =…
Electrino
  • 2,636
  • 3
  • 18
  • 40
1
vote
1 answer

Generate a unique set of complete undirected graphs from a tibble of nodes and sets

I have a tibble like this: Nodes <- tibble( Set = c("A","A","A","B","B","C"), name = c(1,2,3,4,6,5) ) I want to generate a graph that has Nodes as nodes set and Edges <- tibble( from = c(1,1,4), to = c(2,3,6) ) as edges. Of course I want to…
GiulioGCantone
  • 195
  • 1
  • 10
1
vote
0 answers

How to size nodes by weight and height using tidygraph with ggraph in R?

I'm trying to size nodes of a tree by both the weight (which is equivalent to the nodes width in this context) and by it's height. To do this im using both tidygraph and ggraph. For example, if I create some data and turn it into a tidygraph object,…
Electrino
  • 2,636
  • 3
  • 18
  • 40
1
vote
1 answer

Colouring by variable when using tidy graph in R?

I am trying to come up with a way to consistently colour multiple tidygraph plots. Right now, the issue is, when I plot multiple plots to the screen at once, tidygraph chooses a different colour for each variable. hopefully my example below will…
Electrino
  • 2,636
  • 3
  • 18
  • 40
1
vote
2 answers

Reduce the complexity of the algorithm to construct a directed graph (DAG) from an undirected graph that satisfies the given constraints

I have a network of more than 4,000 nodes and I have a list of edges (connections between pairs of nodes). All nodes should converge to a single central point, but I have no way of ordering the nodes, since they are not numbered or labeled in a way…
William
  • 164
  • 11
1
vote
2 answers

Using purrr to map calculations to different networks via tidygraph

The tidygraph package is really fantastic for computing network statistics. However, I have a network with a temporal dimension, and I'd like to calculate network statistics (e.g. centrality) over each of those networks. (E.g. calculate centrality…
jhersh
  • 11
  • 1
1
vote
1 answer

for-loop or apply function on multiple subgraphs

This is a follow-up question to this post Calculation based on list elements. You can find reproducible examples of a graph g and a dataframe modules here Node links across modules with graph and dataframe. From g, I have created a subgraph m1,…
MoonS
  • 117
  • 7
1
vote
1 answer

Splitting a graph by a node

I have a graph, which i would like to split by a node. Which is a presented below. I am using R tidygraph. It has morph functionality with to_split and to_components, but i couldnot find proper documentation to implement it. Any leads will be…
naveen chandra
  • 149
  • 1
  • 7