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
9
votes
1 answer

tidygraph and igraph - build graph from dataframe discrepancy

I can build a graph object in igraph from two dataframes without problems. When I try do the same in tidygraph I get errors. Let me demonstrate. First I load my source data (data from a message…
aterhorst
  • 625
  • 4
  • 14
6
votes
3 answers

Get Edge Data from the tidygraph package

It should be very simple, but I am stuck in this operation. I am interested in extracting the block Edge Data: 23,502 x 3. And to indicate the names of the nodes. In short, I need to know the weight of each pair of nodes by their names. Code: # A…
majesus
  • 303
  • 2
  • 9
6
votes
3 answers

filter in a tidygraph

Consider this simple example library(tidygraph) mynodes <- tibble(id = c(1,2,3,4,5)) myedges <- tibble(from = c(1,1,1,5), to = c(1,2,3,4), power = c(10,10,10,3)) tbl_graph(nodes = mynodes, edges = myedges) # A…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
4
votes
1 answer

Network Diagram with Date Axis

I want to create a directed network visualization with the X-Axis fixed in time. Assuming I have the following…
eitanlees
  • 1,244
  • 10
  • 14
4
votes
1 answer

Network Graph in R

I want to build a network diagram from a dataframe that I have, but I am having troubles. This is what the dataframe looks like. Shop Manager S1 34 S1 12 S2 11 S2 34 S3 34 S4 50 For example, S1 should be connected to S2 and S3…
melisa
  • 95
  • 5
4
votes
1 answer

Tidygraph: obtain sequence of nodes along shortest path

I would like to obtain the sequence of nodes along the shortest path between two nodes using tidygraph. Consider this example. library(tidygraph) library(tidyverse) demo_netw <- tbl_graph(nodes = tibble(node_id = c("A", "B", "C", "D")), …
4
votes
3 answers

Function to find sub ID's of an ID in a data frame

I have a data frame that contains two columns, an ID column and a column with sub ID's that are related to the corresponding ID. The sub ID's can again have sub ID's (in this case the previous sub ID is now an ID). library(tibble) df <- tibble(id =…
jpquast
  • 333
  • 2
  • 8
4
votes
1 answer

Is it possible to resize the relative node size in ggrraph?

New to R; did my best with the rendering my question with the help of with reprex. I have a network with nodes sized by degree, using the ggraph package. The plotted network doesn't look great because some of the nodes are quite small. I would like…
avgoustisw
  • 213
  • 1
  • 7
4
votes
1 answer

Extracting neighborhoods / subgraphs about specific nodes in tidygraph

I'm having some trouble groking certain Tidygraph operations that are relatively straightforward in igraph. In particular I would like to analyze specific neighborhoods at different orders. I think I need to use Morphs for this, but I just haven't…
user131291
  • 147
  • 6
4
votes
5 answers

using tidygraph to merge two edges from the same two nodes into one

I'm struggling to figure out how to collapse 2 edges between the same 2 nodes into 1 and then calculate the sum of these edges. I believe there's a way of doing it in igraph: simplify(gcon, edge.attr.comb = list(weight = "sum",…
rob99985
  • 157
  • 9
4
votes
2 answers

Plot labels for specific geom_node_text

I am trying to plot a network graph and show only the labels for the geom_node_text that have a centrality score above a specific threshold. My code is below: rt_tbl %>% mutate(centrality = centrality_authority()) %>% ggraph(layout = 'kk') +…
mundos
  • 459
  • 6
  • 14
3
votes
1 answer

How do I mark the center node in a tidygraph

Using this reproducable example from another question. How do I label / colour the center node on which the local neighborhood graph is based. (In this case 'x') library(tidygraph) library(ggraph) # Example net <- tibble::tibble(A = letters[1:6], …
Nina van Bruggen
  • 393
  • 2
  • 13
3
votes
1 answer

plot ggraph using supplied node coordinates

As the title says. I have a graph object created using igraph::sample_grg(), which I want to plot using ggraph, with nodes positioned according to the node attributes x and y. What I have tried: Create…
flee
  • 1,253
  • 3
  • 17
  • 34
3
votes
2 answers

Finding the cumulative sum of the value of nodes in a DAG

Suppose I have the following directed acyclic graph (DAG) with each node having a weight of 1. I am interested in calculating the accumulated sum of each node based on the value of its ancestor. Assuming as I said earlier that the weight of each…
William
  • 164
  • 11
3
votes
2 answers

Lowest common ancestor in igraph

Suppose we have a tree in igraph: library(igraph) g <- make_tree(14, children = 3) plot(g, layout = layout_as_tree) Created on 2019-12-21 by the reprex package (v0.3.0) How do we find the lowest common ancestor (LCA) of an arbitrary collection of…
MSR
  • 2,731
  • 1
  • 14
  • 24
1
2 3 4 5 6 7