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 02:18:42 +1000

Thanks Gabor,

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 ?

what I have got so far is:

from igraph import *
import csv
m = []
r = csv.reader(open(r'admat.csv','rb'))
for row in r:
        m.append( [int(i) for i in row] )

g=Graph.Adjacency(m)

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

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

another question, is it possible to measure Freeman node betwenness of the graph ?
to see in how many percentage does it compare to a perfect star ...

and a last question ...
is it possible to get the standard deviation of the average produced by Graph.density() ?

Thanks again

S.



ps: actually I have been subscribed, but I have used a different address to post last time


On Thu, May 22, 2008 at 7:01 AM, Gabor Csardi <address@hidden> wrote:
Szabolcs,

in the next igraph version the row names will be added automatically
as vertex attributes, this has been already added to the
development version.

In the meanwhile, you can use the fact that graph.adjacency keeps
the order of the vertices:

a <- matrix(sample(0:1, 16, rep=TRUE), 4)
rownames(a) <- colnames(a) <- letters[1:4]
g <- graph.adjacency(a)
V(g)$name <- rownames(a)
g

gives:

Vertices: 4
Edges: 9
Directed: TRUE
Edges:

[0] a -> c
[1] b -> b
[2] b -> c
[3] c -> a
[4] c -> b
[5] c -> c
[6] c -> d
[7] d -> b
[8] d -> d

G.

ps. please consider joining the list, otherwise you might miss some
answers, and your messages must be acknowledged "by hand" and that
can cause delay, even a couple of days. Thanks.

On Thu, May 22, 2008 at 01:45:32AM +1000, Szabolcs Feczak wrote:
> Hi,
>
> I have just started to use this tool with R, so far I have achieved
> to read my adjacency matrix from CVS and plot the graph (with the method
> below),
> however I would like to have the vertex labels as the identifiers
> on the rows/columns not the automatically assigned numbers
> how can I do this automatically (I have more actors, the below is just a
> truncated file)
>
>
>
> Thanks
>
> S.
>
> ps: great tool
> -------------------
>
>
> > read.csv(file="out8.csv",head=TRUE,row.names=1,check.names = FALSE)
>        123827 375857 530241 547613 661825 771302
> 123827      0      1      0      0      0      1
> 375857      1      0      0      0      0      1
> 530241      0      0      0      0      1      0
> 547613      0      0      0      0      0      1
> 661825      0      0      1      0      0      0
> 771302      1      1      0      1      0      0
> > graph.adjacency(read.csv(file="out8.csv",head=TRUE,row.names=1,check.names =
> FALSE))
> Vertices: 6
> Edges: 10
> Directed: TRUE
> Edges:
>
> [0] 0 -> 1
> [1] 0 -> 5
> [2] 1 -> 0
> [3] 1 -> 5
> [4] 2 -> 4
> [5] 3 -> 5
> [6] 4 -> 2
> [7] 5 -> 0
> [8] 5 -> 1
> [9] 5 -> 3
> > g8 <- graph.adjacency(read.csv(file="out8.csv",head=TRUE,row.names=
> 1,check.names = FALSE))
> > tkplot(g8, layout=layout.fruchterman.reingold, vertex.size=12, vertex.label=V
> (g8)$name)

> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help


--
Csardi Gabor <address@hidden>    UNIL DGM


reply via email to

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