igraph

R/Igraph Display edge weights in an edge list?

和自甴很熟 提交于 2021-02-07 03:35:42
问题 Is there any way to display edge weights when viewing the graph object as an edge list? I want to do something in the spirit of: get.edgelist(graph, attr='weight') so as to view the edge pairings with the weights listed alongside the nodes, but that seems not to be allowed. Only way I know how to view the weights is to view the network data as an adjacency matrix. Hoping that's not the only way. 回答1: Using the example in the help page for function get.edgelist in pkg:igraph: > cbind( get

R/Igraph Display edge weights in an edge list?

感情迁移 提交于 2021-02-07 03:29:23
问题 Is there any way to display edge weights when viewing the graph object as an edge list? I want to do something in the spirit of: get.edgelist(graph, attr='weight') so as to view the edge pairings with the weights listed alongside the nodes, but that seems not to be allowed. Only way I know how to view the weights is to view the network data as an adjacency matrix. Hoping that's not the only way. 回答1: Using the example in the help page for function get.edgelist in pkg:igraph: > cbind( get

Assign the same index if two vectors have a common intersection

扶醉桌前 提交于 2021-02-05 09:33:12
问题 I need help with a question closely related to some other question of mine. How to merge two different groupings if they are not disjoint with dplyr As the title of the question says, I want to generate an index in a vector that links different vectors in a list if they have an intersection or, if not, if both intersect with some other vector in a list, and so on... This is a question involving graph theory/networks - I want to find indirectly connected vectors. The question above solved my

Assign the same index if two vectors have a common intersection

淺唱寂寞╮ 提交于 2021-02-05 09:32:00
问题 I need help with a question closely related to some other question of mine. How to merge two different groupings if they are not disjoint with dplyr As the title of the question says, I want to generate an index in a vector that links different vectors in a list if they have an intersection or, if not, if both intersect with some other vector in a list, and so on... This is a question involving graph theory/networks - I want to find indirectly connected vectors. The question above solved my

igraph - set node color to categorical vertex attribute

心已入冬 提交于 2021-01-29 20:07:32
问题 I have network g.8 of 24 nodes, and i have set a vertex attribute "country" to for the nodes. I'm trying to set the vertex colors to match the vertex attribute country (n = 10), but the network comes out where nodes have no colour. I get the right colour for the legend though. EDIT: I have managed to get the nodes coloured, but they don't match the colours on the legend at all. The data looks like this: nodes Id Label Country Degree 1 Urabenos Urabenos Colombia 4 2 Sinaloa Cartel Sinaloa

R Igraph subgraph given node index and number of nodes to include in the graph

帅比萌擦擦* 提交于 2021-01-29 12:10:58
问题 I want to plot a portion of a graph according to a specific node and ideally a distance from that node or a number of nodes as part of the sub graph. The data.frame that I am graphing is as follows: Column 1 Column 2 Sequence A B 1 A D 2 D B 3 Z E 4 E D 5 this is the code: network <- graph.data.frame(data_to_graph[,c(1,2)]) subnetwork <- induced.subgraph(network, vids = 30, impl = 'copy_and_delete', eids = c(5,6,7,8,9,10,11,12,13,14,15)) plot(subnetwork) I would like, by specifying an element

nodes labels after deleting in R

白昼怎懂夜的黑 提交于 2021-01-29 10:25:28
问题 I'm working with random graphs where the label of nodes are numbers from 1 to N. In my work, I'm deleting some nodes from the graph. My problem is that in R, after deleting is just renaming the nodes again from 1 to remaining N, how I can preserve the label of nodes after deleting ?? thanks a lot 回答1: If there is no name for a node, the node ID (number) is used to label the graph. To preserve the label, set the name of the nodes to their IDs before removing nodes. Here is a small example.

Graph dataset collection in igraph - not supported now - what is easy way to get these graph to Python?

江枫思渺然 提交于 2021-01-29 10:09:15
问题 The previous versions of powerful graph library "igraph" contained a collection of datasets, in particular: > "immuno" Immunoglobulin interaction network > "macaque" Visuotactile brain areas and connections > "rfid" Hospital encounter network data > "yeast" Yeast protein interaction network Now, unfortunately, these datasets are not supported (at least in Python version). Also repository "Nexus" for these data is not supported. Question: Is there a simple way to find/work with these graphs in

Completely stumped about this error: Error in seq.default(start.at, NROW(data), by = by) : wrong sign in 'by' argument

空扰寡人 提交于 2021-01-29 02:23:45
问题 When I run this code, it works for about 100 iterations of the for loop then throws this error: Error in seq.default(start.at, NROW(data), by = by) : wrong sign in 'by' argument Here is the data that I used, and here is my code... library(igraph) library(zoo) #import network data as edgelist fake.raw.data <- read.csv("fakedata.csv") fake.raw.data <- fake.raw.data[,2:3] as.matrix(fake.raw.data) #create igraph object from edglist data fgraph <- graph_from_data_frame(fake.raw.data, directed =

select subgraph of all connected nodes based on node id

一笑奈何 提交于 2021-01-28 14:23:43
问题 I have a graph composed of 3 subgraphs : person1 <- c(0, 0, 1, 3, 6) person2 <- c(1, 2, 4, 5, 7) id <- c(0,1, 2, 3, 4, 5, 6, 7) person <- c("Marc", "Marc","Eric", "Alan", "Henri", "Adele", "Wil", "Marc") nodes <- data.frame(id, person, stringsAsFactors = FALSE) union_edges <- data.frame(person1, person2) library(igraph) family_tree <- graph_from_data_frame(union_edges) plot(family_tree) How can I a select subgraph of all connected nodes based on node id ? For example, selecting one node ( 1,