igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Re: working with weighted networks (from pajek .net)


From: Gábor Csárdi
Subject: Re: [igraph] Re: working with weighted networks (from pajek .net)
Date: Thu, 2 Sep 2010 11:32:04 +0200

On Thu, Sep 2, 2010 at 11:25 AM, Martin Tomko <address@hidden> wrote:
> Thank you Gabor,
> that helps heaps.
> One last question - I guess the answer must be trivial. Once I get a path
> (get.shortest.paths(...)) between two vertices in a weighted graph, I would
> like to know the length of this path (similar to a vlaue I would get if I
> counted them all using shortes.paths(..., algorithm="dijkstra")). I only get
> a list of visited vertices, as documented.
>
> Is there a way to get this value?

It is the length of the path vector minus one:

sapply(get.shortest.paths(g, 5), length)-1

> And is there a way to dientify edges based on input vertices? I read through
> the documentation and can not find the answer.

What is an input vertex? Adjacent vertex?

E(g)[ adj(v) ]

gives the edges adjacent to vertex v. 'from' and 'to' are similar to
'adj', but consider edge direction as well. There are more examples in
the manual page of 'E' and also here:
http://igraph.sourceforge.net/igraphbook/igraphbook-iterators.html

Gabor

> Thanks
> Martin
>
> On 9/2/2010 11:11 AM, Gábor Csárdi wrote:
>>
>> On Thu, Sep 2, 2010 at 11:07 AM, Martin Tomko<address@hidden>
>>  wrote:
>>
>>>
>>> Thank you guys, that solved my problem.
>>> I suspected that $weight should work, but simple listing of an edge did
>>> not
>>> reveal the attribute. Need to find out how to get the full information
>>> about
>>> the object...
>>>
>>
>> You mean printing everything on the screen? Attributes are not printed
>> by default, but you can print them by giving extra arguments to the
>> print.igraph() function. You can also make printing them the default:
>>
>> igraph.par("print.edge.attributes", TRUE)
>> igraph.par("print.graph.attributes", TRUE)
>> igraph.par("print.vertex.attributes", TRUE)
>>
>> Best,
>> Gabor
>>
>>
>>>
>>> Cheers
>>> Martin
>>>
>>> On 9/2/2010 10:52 AM, Tamas Nepusz wrote:
>>>
>>>>>
>>>>> Sorry, got it working with weights, the appraoch mentionned worked, but
>>>>> what confused me is that there is no access to a g$weights vector. I am
>>>>> still not sure how to get the information for any individual edge.
>>>>>
>>>>>
>>>>
>>>> E(g)[edgeindex]$weight seems to work for me in igraph 0.5.3. The only
>>>> thing to watch out for is that edges are indexed from zero, not 1, so
>>>> E(g)[1]$weight gives the weight of the second edge.
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM



reply via email to

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