igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Hops in graph


From: Gábor Csárdi
Subject: Re: [igraph] Hops in graph
Date: Tue, 6 Apr 2010 09:43:25 +0100

Hello Surendar,

On Mon, Apr 5, 2010 at 10:47 PM, Surendar Swaminathan
<address@hidden> wrote:
> Hello Graph experts,
>
>   I am trying to find number of hops between any two nodes for the
> whole graph.
> for example if I say
>
> Node1    Node2
>
> 1              2
> 2              3
> 3              4
>
> I want to say from "1" to "4" it has to pass through "2" and "3". So,
> total number of hops would be 2.
>
> Is there anyways I can do this in Igraph.
>
> tab<- read.csv("flie.csv")
> g<-graph.data.frame(tab,directed=False)
> g1<-shortest.paths(g)

What is wrong with this code? (Except that 'False' should be 'FALSE'.)
The only difference between 'shortest.paths' and your definition is
that you need to subtract one from the 'shortest.paths' result.
'shortest.paths' is counting the edges, and you're counting the nodes
along the path.

> How do I output this in excel sheet to read them?

Please see the 'write', 'write.table' and 'write.csv' functions. You
can import the CSV file into Excel directly.

Best,
Gabor

> What is the better way to output this result ?
> Help on this would be great.
>
> Thanks
> Surendar
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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