[Top][All Lists]

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

Re: [igraph] Named vertexes from imported adjacency matrix

From: Szabolcs Feczak
Subject: Re: [igraph] Named vertexes from imported adjacency matrix
Date: Sun, 1 Jun 2008 15:19:02 +1000


Meanwhile I made progress after reading the slim document and guessing
around for 5 hours :D

so some of my questions I can answer myself, but some remain

it works, however meanwhile Im trying to do the same with the python interface
as I might have to do batch processing and it seems to be easier that way

How would I do the same thing in python ?

well I do not know how would I make the same result from the same input,
but I have converted my input file into ncol format and than I could read it much easier

so from my original csv


I made this

ikon.DEV fors.DEV 9
ikon.DEV matt.DEV 5
astr.DEV matt.DEV 6
astr.DEV ikon.DEV 35
dark.EXT ikon.DEV 5
inca.EXT ikon.DEV 5
inca.EXT astr.DEV 7
ossm.DEV ikon.DEV 5

and I could read it easily with

g=Graph.Read_Ncol("ncol", names=True, weights=True, directed=False)

however I have realized that it works a bit different and the Adjacency function ignores non numeric values
so I had to edit the csv by hand and remove the first column and the first row

the above conversion method eliminated this problem as well

also, how would I display the weights on the graphs
what I would like to achieve is something like this


it would be nice to have both the line width and the frequencies

I could make the widths:
weights = [edge["weight"] for edge in g.es]
max_weight = max(weights)
g.es["width"] = [1+9*(weight/max_weight) for weight in weights]

but I still do not know how to plot the numeric
values of the weights onto the image
Is this possible ?

Another question popped up meanwhile,
how would I set the margin on the output ?

I have tried

no luck

also how would I modify the position of the labels ?
so actually Im close to what I would like

now I have

Would it be possible to give a white or light gray background to the vertex labels so they would cover the lines behind them
to make it much easier to read the labels ?

or even opacity would be nice, I have seen that there is possibility to print layers on the canvas gradually with different opacity
however I could not figure out how would I print the labels and the rest of the image separately

for those who seek working examples of python code with igraph I put down the whole code here for future reference
generating  http://feczo.nmi.rulez.org/sna/13833-2.png from the above input matrix
note: you need the cairo python library for png output

from igraph import *

g=Graph.Read_Ncol("ncol", names=True, weights=True, directed=False)

weights = [edge["weight"] for edge in g.es]
max_weight = max(weights)

color = ["#003300", "#006600", "#009900", "#00CC00", "#00FF00",
        "#33FF00", "#66FF00", "#99FF00", "#CCFF33", "#CCFF00",
        "#000033", "#000066", "#000099", "#0000CC", "#0000FF",
        "#330033", "#660066", "#990099", "#CC00CC", "#FF00FF",
        "#330000", "#660000", "#990000", "#CC0000", "#FF0000"]

g.es["width"] = [1+9*(weight/max_weight) for weight in weights]
g.es["color"] = [color[int(round(24*weight/max_weight))] for weight in weights]
g.vs["size"] = [10+20*cent for cent in g.evcent()]
g.vs["color"] = ["lightblue" for i in g.vs]


My questions still:
is it possible to measure Freeman node betwenness of the graph ?
to see in how many percentage does it compare to a perfect star ...
is it possible to get the standard deviation of the average produced by Graph.density() ?



reply via email to

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