Tidygraph provides a tidy framework in R for all things relational (networks/graphs, trees, etc.). It is often used alongside ggraph.
Questions tagged [tidygraph]
102 questions
1
vote
1 answer
Reshaping a data frame with a list column produced by tidygraph
I am working with the tidygraph package and try to find a "tidy" solution
for the example below. The problem is not really tied to tidygraph and more about data wrangling but I think it is interesting for people working with this package.
In the…

Alex
- 4,925
- 2
- 32
- 48
1
vote
1 answer
simplify tree removing nodes
I have a non-cyclical graph that can be considered a tree. Here's a simplified example:
library(tidygraph)
create_tree(20,2, directed = TRUE, mode="in") %>% plot
The real-life example can be a little more complicated, as I may have multiple paths…

dmi3kno
- 2,943
- 17
- 31
1
vote
1 answer
Propagate value from children with tidygraph
I have a tree annotated at genus level (ie each leaf has a name) and I want to propagate the color of the leaves in the branches/edges as long as the children have the same genus, like in this plot:
Source
My tree is here (sorry, dput doesn't…

abichat
- 2,317
- 2
- 21
- 39
0
votes
1 answer
Error in tidygraph `as_tbl_graph` - mutliple logicals compared to single
I encountered an issue in the tidygraph package.
Here is an example code:
library(tidygraph)
adj <- structure(c(0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
…

Moritz Schwarz
- 2,019
- 2
- 15
- 33
0
votes
1 answer
R ggraph: how to plot bi-directional arrows in network?
I would like to do a network graph in R using ggraph where an an edge relationship goes both ways A -> B and B -> A. I would like top plot this with ggraph as a single bi-directional arrow? A solution on ggraph's Github issue is to use…

Matifou
- 7,968
- 3
- 47
- 52
0
votes
0 answers
get the name of the leave connected for each node with tidygraphe
i have multiple trees (that are more path). so basicaly each node are connected with a direction to one path or none.
i want to know for each of them the ultimate descendants ( that could be himself).
i try to do it with tidygraph.
demo_netw <-…

francois
- 135
- 3
- 9
0
votes
2 answers
ggraph node color and legend not matching
This is my tidygraph object which I'm trying to plot
hub_plot1
# A tbl_graph: 50 nodes and 540 edges
#
# An undirected simple graph with 2 components
#
# Node Data: 50 × 4 (active)
name mod kme color
1…

PesKchan
- 868
- 6
- 14
0
votes
0 answers
Fixed descending Tidygraph (igraph) position of nodes
I trying to learn tidygraph to illustrate relationships between employees and external entities (suppliers). The relationships could have multiple nodes, example: the employee owns a % of a company that owns a % of the supplier etc.
With a sample…

Chamkrai
- 5,912
- 1
- 4
- 14
0
votes
1 answer
Subset igraph plot in using activate function in R
I am trying to subset an igraph plot to display certain nodes based on a given vertex attribute. I have to subset them in the plot output to preserve the layout for the vertices. My code is the following:
plot.igraph(graph, layout=lo,…

flâneur
- 633
- 2
- 8
0
votes
1 answer
Plotting pi digits as connection bundles with ggraph
I'm looking to plot the digits of Pi as heirarchical edge bundles, as shown in this image
Here, the digits of Pi are grouped by their colour, and then each digit has an edge drawn to the digit that follows it (i.e., if Pi is 3.141, then 3 would…

Conor Neilson
- 1,026
- 1
- 11
- 27
0
votes
0 answers
all_simple_paths() in igraph in R is taking too much time
I am trying to solve a trip assignment problem (transport planning). Available data is this: trips between nodes and links shapefile with 'from' and 'to' (match with those in trips data) codes. The approach i am adopting is this:
take each…

Satya Pamidi
- 143
- 8
0
votes
1 answer
Label tree branches in tidygraph
I have a rooted forest with 116 trees as a tidygraph object. I now want to add a new property to the nodes, i.e. label the nodes within the branches.
For instance, for a graph
a <- tibble(from = c(1, 2, 3, 3, 4, 5, 7, 8, 8, 9, 10),
to =…

Pascal
- 563
- 1
- 3
- 15
0
votes
1 answer
Generating multiple network graphs with attributes from csv with ggraph, tidygraph in R
I have three csv files which looks like this:
node <- data.frame(
object = c("2-1887", "2-1887", "2-1887", "2-1887", "2-1887", "2-1887", "2-1887", "4-1889", "4-1889", "4-1889", "4-1889", "4-1889", "4-1889", "4-1889"),
id = c(1, 2, 3, 4, 5, 6, 7, 1,…

HSJ
- 687
- 6
- 16
0
votes
1 answer
How to speed up case_when/conditional mutate?
One can notice that case_when do not evaluate in the formula the subset of the tibble when condition is met, but the whole tibble, an example:
picks = c(1:3)
a = tibble(id = c(1:4),
k = NA)
a %>% mutate(
k = case_when(id %in%…

GiulioGCantone
- 195
- 1
- 10
0
votes
0 answers
Why does OD matrix in sfnetwork returns one NA in dimension names?
I have a rooted tree with spatially explicit edges representing a river network (new_net). I want to compute an origin-destination (OD) matrix to get the distances between multiple points representing small catchment outlets (1754 points) located on…

MerlinLutin
- 1
- 1