igraph-help
[Top][All Lists]
Advanced

[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

Hi

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

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

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

http://feczo.nmi.rulez.org/sna/2232.png

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
plot(g,target="out.png",layout="reingold_tilford_circular",vertex_label=g.vs["name"],vertex_label_color="#FF4400",bbox=(0,0,960,620),margin=(10,10,10,10))

no luck

also how would I modify the position of the labels ?
 
so actually Im close to what I would like
http://feczo.nmi.rulez.org/sna/13833.png

now I have
http://feczo.nmi.rulez.org/sna/13833-2.png

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]

plot(g,target="out.png",layout="reingold_tilford_circular",vertex_label=g.vs["name"],vertex_label_color="#FF4400",bbox=(0,0,960,620))



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() ?


Thanks

S.

reply via email to

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