igraph

How arrange diagram in R

谁说胖子不能爱 提交于 2019-12-12 04:03:11
问题 I want to get diagram similar to picture below, but code I use creates different diagram. With rbind I added some hierarchy to a diagram. In data frame col0 there is a string with names of animals. In col1 string is split into individual animals & col2 is adding latin name for a animal. col1 data are always changing and in col2 data constant (there always be feline or canis names in that column). library(igraph) # I create my dataframe with animals df <- data.frame(col0 = c("Cat Dog Wolf",

Saving the results of each iteration of a for-loop in R as a network object using the filename

五迷三道 提交于 2019-12-12 03:43:58
问题 I'm attempting to run a loop to iterate through a number of adjacency lists saved as .csv files, convert them to edge lists, and network objects, and save each of these using the filename. The problem is a) the code appears to cycle through the list of filenames but not produce any output b) it won't save the network objects using the filenames (it appears to overwrite each time). Note that the code works fine for an individual file identified by "filename.csv" in replacement of the "f"s in

igraph layout_reingold_tilford gives errors

拈花ヽ惹草 提交于 2019-12-12 03:42:57
问题 I get the following error message when trying to use the layout_reingold_tilford layout File "C:\Python27\lib\site-packages\igraph\layout.py", line 80, in init self._coords = [list(coord) for coord in coords] TypeError: 'int' object is not iterable I have found the following question which has a simple question and answer but when I try the example I get the same error Plot a tree-like graph with root node at the top import igraph as ig g = ig.Graph(n = 12, directed=True) g.add_edges([(1,0),

delete.edges doesn't work in igraph

馋奶兔 提交于 2019-12-12 03:16:32
问题 I want to delete all edges that link to node '1' but the function delete.edges doesn't work: g<-graph.full(n=10, directed = TRUE, loops = FALSE) g <- delete.edges(g,c(2,1,3,1,4,1,5,1,6,1)) plot(g) When viewing the graph, nothing changes! what is the problem ? 来源: https://stackoverflow.com/questions/35040517/delete-edges-doesnt-work-in-igraph

How can I access the 'epath' output of get.shortest.paths to get the edge names?

一世执手 提交于 2019-12-12 02:44:59
问题 I would like to access the 'epath' output of the get.shortest.paths and get the names of the edges, rather than the ID's. At the moment, I have the edge ID's, but I need the names of the edges. For example: # create graph solid = graph_from_literal(A-D,A-C,D-F,D-C,C-B,B-E) # get edges of shortest paths solid.epaths = get.shortest.paths(solid, from = 1, to = V(solid),output = 'epath') # get verticies of shortest paths solid.vpaths = get.shortest.paths(solid, from = 1, to = V(solid),output =

OpenCPU error HTTP 400 Not a graph object

偶尔善良 提交于 2019-12-12 02:44:11
问题 I m using Angularjs and OpenCPU to calculate some data through Igraph R Package Graph is a adjacency matrix/Array generate by java script [[0,1,1,0,1,1,0,0,0,1,1,1,1,1],[1,0,1,1,1,1,1,1,1,1,0,1,1,1],[1,1,0,1,0,1,1,1,1,1,1,1,1,1],[0,1,1,0,1,0,0,0,0,1,0,1,0,0],[1,1,0,1,0,1,0,0,0,1,1,0,1,0],[1,1,1,0,1,0,0,1,0,1,1,1,1,1],[0,1,1,0,0,0,0,1,0,0,1,1,1,1],[0,1,1,0,0,1,1,1,1,1,0,1,0,1],[0,1,1,0,0,0,0,1,0,1,1,0,0,0],[1,1,1,1,1,1,0,1,1,0,0,0,0,1],[1,0,1,0,1,1,1,0,1,0,0,0,1,1],[1,1,1,1,0,1,1,1,0,0,0,0,1,1

igraph multicolor for a single vertex label text

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:08:32
问题 This might be too much to ask, but is it possible to color only part of the label text? For example, I have a vertex with 2-line label, and I want the first line in black font and the second line in red font. Anything can be done? Many thanks!! 回答1: You can put the labels manually (if there is no other way). library(igraph) g1 <- graph.atlas(sample(0:1252, 1)) layout1 <- layout.fruchterman.reingold(g1) plot(g1, layout = layout1) layout2 <- apply(layout1, 2, function(x) { x <- x / (max(x)-min

The first 10 shortest paths in a graph - Igraph 0.6 - Python 2.7

本秂侑毒 提交于 2019-12-12 01:09:16
问题 I was wondering about this ever since I've started to successfully implement Igraph into my coding: Can you retrieve with get_all_shortest_paths as many shortest paths as you like. Let's say first 10. I've understood so far that retrieving ALL shortest paths in a undirected graph is non-sense since in most cases you have infinite amount of them. But can I simply retrieve first 10 shortest paths? I've tried to achieve this with an undirected g = Graph() : list = [] list.append(g.get_all

Calculating the shortest path between any two vertices u,v in G

一笑奈何 提交于 2019-12-11 19:07:45
问题 I want to find the set S that contains the shortest path between any two vertices in a graph. The following code is working fine, but I am not sure if there is a more efficient code that does the same functionality. def getShortestPaths(g): shortestPaths = [] #iterate all pair of nodes for x in itertools.combinations(g.vs["label"], 2): path = len(g.get_shortest_paths(v=x[0],to=x[1])[0]) - 1 shortestPaths.append(path) return shortestPaths 回答1: The efficiency of your current code depends on the

assign a (numeric real) value to vertex in network graph

别说谁变了你拦得住时间么 提交于 2019-12-11 18:54:45
问题 I wanted to assign or associate each node in the network plot with some real value (say some score) in R . Which need to be updated in iterations. Finally to plot the network graph with size of vertex according to its latest value (score). Which property of a vertex I can use for this purpose and how? If it's not possible in igraph , is there any other way to achieve this purpose in R ? I'm new to R . Anybody please help me to sort out this problem. 回答1: I create my gaph graph2 <- read.table