Questions tagged [igraph]

igraph is a free software package for creating and manipulating large undirected and directed graphs. It is written in C, but has interfaces to higher-level languages like R, Python or Mathematica.

igraph includes implementations for classic graph theory problems like minimum spanning trees and network flow, and also implements algorithms for some recent network analysis methods (e.g., community structure search).

igraph is a collection of network analysis tools with the emphasis on efficiency, portability and ease of use. igraph is open source and free. igraph can be programmed in R, Python, Mathematica and C/C++.

Repositories

Related links

3934 questions
14
votes
4 answers

Find immediate neighbors by group using data table or igraph

I have a data.table: groups <- data.table(group = c("A", "B", "C", "D", "E", "F", "G"), code_1 = c(2,2,2,7,8,NA,5), code_2 = c(NA,3,NA,3,NA,NA,2), code_3 = c(4,1,1,4,4,1,8)) group…
User2321
  • 2,952
  • 23
  • 46
14
votes
3 answers

Lots of edges on a graph plot in python

I have following script: import pandas as pd from igraph import * df_p_c = pd.read_csv('data/edges.csv') ... edges = list_edges vertices = list(dict_case_to_number.keys()) g = Graph(edges=edges, directed=True) plot(g, bbox=(6000, 6000)) I have…
CezarySzulc
  • 1,849
  • 1
  • 14
  • 30
14
votes
2 answers

Get subgraph of shortest path between n nodes

I have an unweighted graph and I want to get a subgraph that has just the nodes and edges that contain the shortest paths between n known nodes. In this case 3 nodes (11, 29, & 13 are the names). Question How can I get a subgraph of shortest path…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
14
votes
2 answers

increasing the distance between igraph nodes

I have a graph that I have produced using igraph. I'd like to spread out the nodes. The only way I have found so far to do this is to scale the layout and force the plot command to not rescale. png("kmeansColouredNetwork.png", width=1200,height =…
Ben
  • 401
  • 2
  • 6
  • 15
14
votes
3 answers

How to plot a bipartite graph in R

How do I plot a network of type bipartite in R? Similar to this: I have similar data but with weights for both genes and diseases and SARS. This network is an example. I have different kind of attributes. I followed a link here. But due to my…
Pankaj
  • 1,296
  • 2
  • 13
  • 23
14
votes
4 answers

Colored graph isomorphisms: 1(red)->2(blue) vs 1(blue)->2(red)

Given two simple graphs: library(igraph) g <- graph.empty() g <- g + vertices(1,2,3) g <- g + path(1,2,3) g1 <- g V(g1)$color = c(1,2,2) g2 <- g V(g2)$color = c(2,1,1) which look…
alberto
  • 2,625
  • 4
  • 29
  • 48
14
votes
5 answers

Failing to install python-igraph

I'm trying to install python-igraph. After I run sudo pip install python-igraph I got the following log: Downloading/unpacking python-igraph Downloading python-igraph-0.7.1-1.tar.gz (375kB): 375kB downloaded Running setup.py egg_info for package…
Sergey Ivanov
  • 3,719
  • 7
  • 34
  • 59
14
votes
1 answer

Using igraph in python for community detection and writing community number for each node to CSV

I have an network that I would like to analyze using the edge_betweenness community detection algorithm in igraph. I'm familiar with NetworkX, but am trying to learning igraph because of it's additional community detection methods over NetworkX. My…
CurtLH
  • 2,329
  • 4
  • 41
  • 64
14
votes
3 answers

How to separate edge label from edge in igraph?

I would like to move the position of the edge label so that it is not on top of it. Here is a little example: g <- graph.empty(n=3) g <- graph(c(1,2,3,2,1,3), directed=T) E(g)$weight <- c(3,2,5) plot(g, edge.label = E(g)$weight) In my…
user31168
  • 165
  • 1
  • 5
14
votes
4 answers

How to create weighted adjacency list/matrix from edge list?

My problem is very simple: I need to create an adjacency list/matrix from a list of edges. I have an edge list stored in a csv document with column1 = node1 and column2 = node2 and I would like to convert this to a weighted adjacency list or a…
Milo
  • 185
  • 1
  • 1
  • 9
13
votes
2 answers

Fast way to group variables based on direct and indirect similarities in multiple columns

I have a relatively large data set (1,750,000 lines, 5 columns) which contains records with unique ID values (first column), described by four criteria (4 other columns). A small example would be: # example library(data.table) dt <-…
R. Lima
  • 412
  • 4
  • 15
13
votes
1 answer

meaning of weights in community detection algorithms

There is an excellent comparison of community detection algorithms available in igraph here. However, there's some ambiguity about the use of weights in the algorithms that can be applied with weighted edges. Typically, edge weights will be oriented…
JenB
  • 17,620
  • 2
  • 17
  • 45
13
votes
1 answer

Rewiring weighted graph produces NAs

A previous answer to another question provided some code to rewire a weighted graph as: g <- graph.ring(10) E(g)$weight <- seq_len(ecount(g)) E(g)$weight # [1] 1 2 3 4 5 6 7 8 9 10 is.weighted(g) # [1] TRUE g2 <-…
user1320502
  • 2,510
  • 5
  • 28
  • 46
13
votes
3 answers

How do I find the number of vertices in a graph created by iGraph in python?

I'm writing a function that receives a graph as input. The very first thing I need to do is determine the order of the graph (that is, the number of vertices in the graph). I mean, I could use g.summary() (which returns a string that includes the…
Austin Williams
  • 173
  • 1
  • 2
  • 10
13
votes
1 answer

Pseudo-code for Network-only-bayes-classifier

I am trying to implement a classification toolkit for univariate network data using igraph and python. However, my question is actually more of an algorithms question in relational classification area instead of programming. I am following…
Sait
  • 19,045
  • 18
  • 72
  • 99