igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] graph from an adjacency matrix


From: Jan Zaucha
Subject: Re: [igraph] graph from an adjacency matrix
Date: Fri, 27 Feb 2015 16:53:34 +0000

Hi again, 
Regarding the OSX version I now managed to install cairo, but it doesn't work properly:

Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

I get the same error when I simply try importing cairo into python. 

Jan

On 27 February 2015 at 14:30, Jan Zaucha <address@hidden> wrote:
Thanks Tamas,

This seems to be very easy to use, but I have trouble with the graphics software:

On my Linux desktop when I run 'plot' the script freezes  -after a few seconds the CPUs go idle, no output goes to the terminal, no windows open, when I ctrl-c out I also get no information on what the script was doing, it just terminates. 

I also tried on my OSX laptop, but here I ran into trouble with installing the pycario graphics library interface. I download the source code but './configure' fails with the error: configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."
I have tried googling for the solution, installed a few suggested libraries with brew but had no success. 

Any ideas on how to proceed on either of the systems?

Jan

On 25 February 2015 at 09:32, Tamas Nepusz <address@hidden> wrote:
Hi Jan,

> I have different datasets- the smallest networks consist of 80 nodes, the
> largest even 10,000 (yes I have a lot of RAM), but I'm happy to only
> visualise the small ones. At the moment I've got a numpy matrix, but I can
> convert it into a list of lists or anything else that is needed.
> [...] And additionally I have a list (or numpy array) with node labels, and
> another list with binary values which I would like to use to specify the node
> colour.

Then it is probably as simple as:

import igraph
import numpy

# ...create your NumPy matrix in m...

# if you want to keep only edges with a weight above a certain cutoff:
m[m < cutoff] = 0.0

# create the graph
g = igraph.Graph.Weighted_Adjacency(m)

# construct a layout
layout = g.layout_fruchterman_reingold(weights=g.es["weight"])

# construct the plot settings
plot_settings = dict(
        layout=layout,
        edge_width=igraph.rescale(g.es["weight"], out_range=(0.0, 5.0)),
        vertex_label=any_list_of_strings,
        vertex_color=["red" if value else "blue" for value in any_list_of_booleans]
)

# plot the graph
plot(g, **plot_settings)

See the documentation of Graph.Weighted_Adjacency(),
Graph.layout_fruchterman_reingold(), Graph.__plot__() and rescale() for more
information.

All the best,
Tamas



--
Jan Zaucha
Bristol Centre for Complexity Sciences
Computational Genomics Group
University of Bristol



--
Jan Zaucha
Bristol Centre for Complexity Sciences
Computational Genomics Group
University of Bristol

reply via email to

[Prev in Thread] Current Thread [Next in Thread]