igraph

How to seed graph generator in python-igraph?

╄→尐↘猪︶ㄣ 提交于 2020-01-24 18:01:26
问题 Is there any way to seed the following Watts-Strogatz graph generated using python-igraph, so that each time I run the script I get the same realization of SW graph ? import igraph graph = igraph.Graph.Watts_Strogatz(1, N, nei, p) where N is the number of nodes, nei the number of connected neighbors, and p the rewiring probability. 回答1: igraph uses the built-in RNG of Python so you can seed that: In [1]: import random In [2]: random.seed(1234) In [3]: g=Graph.Watts_Strogatz(1, 100, 2, 0.25)

Input to fit a power-law to degree distribution of a network

北城余情 提交于 2020-01-24 10:31:32
问题 I would like to use R to test whether the degree distribution of a network behaves like a power-law with scale-free property. Nonetheless, I've read different people doing this in many different ways, and one confusing point is the input one should use in the model. Barabasi, for example, recommends fitting a power-law to the 'complementary cumulative distribution' of degrees (see Advanced Topic 3.B of chapter 4, figure 4.22). However, I've seen people fit a power-law to the degrees of the

How to calculate a (co-)occurrence matrix from a data frame with several columns using R?

自闭症网瘾萝莉.ら 提交于 2020-01-24 04:04:09
问题 I'm a rookie in R and currently working with collaboration data in the form of an edge list with 32 columns and around 200.000 rows. I want to create a (co-)occurrence matrix based on the interaction between countries. However, I want to count the number of interactions by the total number of an object. Basic Example of Aspired Outcome If in one row "England" occurs three times and "China" only one time, the result should be the following matrix. England China England 3 3 China 3 1

Delete weak correlations from network in igraph (vertices and edges)

和自甴很熟 提交于 2020-01-23 09:10:12
问题 I need to plot a network from a correlation matrix. A small subset of my data: Taxon CD1 CD2 Actinomycetaceae;g__Actinomyces 0.072998825 0.031399459 Coriobacteriaceae;g__Atopobium 0.040946468 0.002703265 Corynebacteriaceae;g__Corynebacterium 0.002517201 0.006446247 Micrococcaceae;g__Rothia 0.001174694 0.002703265 Porphyromonadaceae;g__Porphyromonas 0.023326061 0.114368892 Prevotellaceae;g__Prevotella 0.252894781 0.102308172 Flavobacteriaceae;g__Capnocytophaga 0.001174694 0.029320025

Convert igraph object to a data frame in R

不羁的心 提交于 2020-01-23 04:30:27
问题 I'm working with the iGraph library and I need to run some statistical analysis on the network. I'm computing several variables using iGraph and then want to use those indicators as the dependent variable in a few regressions and the vertex attributes as the independent variables in the model. So, I'm able to load the data, run the igraph analysis, but I'm having trouble turning the igraph object back into a data frame. I don't really need the edges to be preserved, just each vertex to be

igraph edge between two vertices

杀马特。学长 韩版系。学妹 提交于 2020-01-23 02:54:06
问题 I'm new to R and igraph and I was wondering if anybody can help me with the following. I want to find the edge weight between two vertices in a graph. My graph structure is defined by the normal ego (node1), alter (node2) and the weight of the edge between them. I know that I can get the weight for each of the edges in the list of edges that originate from node number 5 using E(igraph_friendship) [ from(5) ]$weight And that I can find the weight for each of the edges in the list of edges that

Python igraph: get all possible paths in a directed graph

不羁的心 提交于 2020-01-21 05:35:49
问题 I am using igraph (Python) and would like to get all possible paths between two nodes in a directed graph. I am aware of the function get_all_shortest_paths , which is for shortest paths, but could not find a general one. Update: My main goal is to get all nodes in these paths, so that I can then get a subgraph of these nodes. 回答1: Since you mentioned in your question that your ultimate goal is to get only the nodes that are in these paths and not the paths themselves, I think you don't even

Deleting an edge in graph for C

五迷三道 提交于 2020-01-17 06:18:27
问题 I'm trying to delete a randomly selected edge form a igraph (http://igraph.org/c/) graph called "g". Igraph's manual for "igraph_delete_edges" function is here: http://igraph.org/c/doc/igraph-Basic.html#igraph_delete_edges But it's still not enough for me to figure it out. I've got this: #include <stdio.h> #include <igraph/igraph.h> int main() { igraph_t g; igraph_vector_t v; igraph_vector_t edges; igraph_vector_init(&edges,0); igraph_vector_t indices; igraph_vector_init(&indices, 0); igraph

the correct use and interpretation of `modularity()`

[亡魂溺海] 提交于 2020-01-16 03:55:08
问题 In the igraph ?modularity section there is example code given as g <- graph.full(5) %du% graph.full(5) %du% graph.full(5) g <- add.edges(g, c(1,6, 1,11, 6, 11)) wtc <- walktrap.community(g) modularity(wtc) #[1] 0.5757575 modularity(g, membership(wtc)) #[1] 0.5757576 the output of wtc shows: wtc #Graph community structure calculated with the walktrap algorithm #Number of communities (best split): 3 #Modularity (best split): 0.5757575 #Membership vector: # [1] 3 3 3 3 3 1 1 1 1 1 2 2 2 2 2 I am

how to create a network having edge list and node list in two different csv file using igraph in R?

隐身守侯 提交于 2020-01-15 13:33:29
问题 what I am trying to do is to create a network using igraph in R my data includes : 1. edge list in a CSV file like this one call it book a b 1 2 2 3 5 1 2.node list in a CSv File like this one call it name c 1 2 3 4 5 this is the code : library(igraph) # Import Data relations=read.csv("book.csv",head=TRUE) # Load (UNDIRECTED) graph from data frame network=graph.data.frame(relations,directed=FALSE) ecount(network) Vcount(network) summary(network) #visualizing the network tkplot(network,vertex