igraph-help
[Top][All Lists]
Advanced

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

[igraph] Re: Assign Weight to Link by Counting Repetitions


From: Lorenzo Isella
Subject: [igraph] Re: Assign Weight to Link by Counting Repetitions
Date: Mon, 05 Oct 2009 11:48:06 +0200
User-agent: Thunderbird 2.0.0.23 (X11/20090817)


Date: Fri, 2 Oct 2009 12:17:32 +0200
From: G?bor Cs?rdi <address@hidden>
Subject: Re: [igraph] Assign Weight to Link by Counting Repetitions
To: Help for igraph users <address@hidden>
Message-ID:
        <address@hidden>
Content-Type: text/plain; charset=ISO-8859-1

Lorenzo,

see ?count.multiple, the last example on the manual page actually does
exactly what you want.

Best,
Gabor

Dear Gabor and dear Tamas,
Thanks for your suggestions, which both answer my question.
Now, there is only one thing that bothers me: how to remove vertexes when I use numbers as vertex names. See the code snippet to read the adjacency list (saved in file graph_test.dat and copied at the end of the email)

rm(list=ls())
library(igraph)

tab <- read.table("graph_test.dat",header=FALSE)

g <- graph.data.frame(tab, dir=FALSE)

E(g)$weight <- count.multiple(g)

g <- simplify(g)


I then get easily the properties of the graph

> g
Vertices: 4
Edges: 2
Directed: FALSE
Edges:
[0] '174514432' -- '95879170'
[1] '74514432'  -- '95879170'
> V(g)
Vertex sequence:
[1] "174514432" "78774272"  "74514432"  "95879170"

and I can e.g. remove vertex 1 by issuing the command

> delete.vertices(g, V(g)[1])

However, in general I read the ID's of the vertices to be removed from another file. Neither using them as an array or as strings works for me. E.g. if I re-read the graph and try to get rid of its first vertex by using its ID as printed out above

> delete.vertices(g, "174514432")
Error in delete.vertices(g, "174514432")
At iterators.c:721 : Cannot create iterator, invalid vertex id, Invalid vertex id

or as a numeric array

> delete.vertices(g, c(74514432))
Error in delete.vertices(g, c(74514432)) :
At iterators.c:721 : Cannot create iterator, invalid vertex id, Invalid vertex id


In other words: which kind of data type is V(g)[1]? It looks like a string, but probably it is not (and should not be, according to the delete.vertices documentation).
Many thanks

Lorenzo


174514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170
78774272 78774272
74514432 95879170







reply via email to

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