igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] extracting lists


From: Gábor Csárdi
Subject: Re: [igraph] extracting lists
Date: Tue, 27 Jan 2009 20:56:45 +0100

On Tue, Jan 27, 2009 at 8:48 PM, Thiago M. Venancio
<address@hidden> wrote:
> Sorry about the lack of details.
>
> E(graph) gives a list of edges.
>
> Now imagine you have the edge betweenness for every edge and you want to
> create a data frame with:
>
>  NODE1 -- NODE2   betweenness

bet <- edge.betweenness(g)
el <- get.edgelist(g)
data.frame(from=el[,1], to=el[,2], betweenness=bet)

G.

> How would you do that ?
> With the data frame created I know how to export to the format I need.
>
> Thanks.
>
> Thiago
>
> On Tue, Jan 27, 2009 at 2:42 PM, Gábor Csárdi <address@hidden> wrote:
>>
>> On Tue, Jan 27, 2009 at 7:11 PM, Thiago M. Venancio
>> <address@hidden> wrote:
>> > Thanks Gabor. It worked perfectly.
>> >
>> > A related question: How can one export the edge labels ?
>>
>> You mean into a file? Use a format that supports them, e.g. GraphML or
>> GML.
>>
>> > There is no attribute name in edges
>> > I would like to recover the data like it appear when querying:
>> > NODE1   -- NODE2
>>
>> Where are the edge labels here? I am a bit confused about what you want.
>>
>> G.
>>
>> > Best,
>> >
>> > Thiago
>> >
>> > On Tue, Jan 27, 2009 at 3:36 AM, Gábor Csárdi <address@hidden>
>> > wrote:
>> >>
>> >> V(g)$name gives the vertex names.
>> >>
>> >> G.
>> >>
>> >> On Tue, Jan 27, 2009 at 12:46 AM, Thiago M. Venancio
>> >> <address@hidden> wrote:
>> >> > Hi,
>> >> >
>> >> > The file graph.txt is a ncol format graph.
>> >> > I got a clue here. What happens is that the V(graph) command returns
>> >> > an
>> >> > integer type data that starts in the position zero. So, the degree in
>> >> > deg[1]
>> >> > is relative to vec[0] vertex.
>> >> > I would like to transform the vec (integer type) to get a vector with
>> >> > node
>> >> > names (not numerical IDs). Every time I use as.vector and relative
>> >> > commands
>> >> > I get the numerical IDs and not the names.
>> >> >
>> >> > Hope you can help me now with the additional info provided.
>> >> >
>> >> > Thanks.
>> >> >
>> >> > Thiago
>> >> >
>> >> > On Mon, Jan 26, 2009 at 5:56 PM, Gábor Csárdi <address@hidden>
>> >> > wrote:
>> >> >>
>> >> >> On Mon, Jan 26, 2009 at 10:23 PM, Thiago M. Venancio
>> >> >> <address@hidden> wrote:
>> >> >> > Hi all,
>> >> >> >
>> >> >> > After loading the graph in R, I would like to extract the list
>> >> >> > with
>> >> >> > vertices
>> >> >> > names and their degrees.
>> >> >> > I know how to save both variables in vectors, however they seem to
>> >> >> > be
>> >> >> > in
>> >> >> > different orders. For example, the degree of the first element in
>> >> >> > the
>> >> >> > vector
>> >> >> > with vertices names is not allocated in the first position in the
>> >> >> > degree
>> >> >> > vector.
>> >> >> > Here is what I am doing:
>> >> >> >
>> >> >> > graph = read.graph("graph.txt", format="ncol")
>> >> >> > deg = degree(graph)
>> >> >> > vec = V(graph)
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> it is hard to guess what is in 'graph.txt', but 'deg' and 'vec' are
>> >> >> "in order" here, i.e. deg[1] belongs to vec[1], etc.
>> >> >>
>> >> >> You need to give us a reproducible example to see what goes wrong
>> >> >> for
>> >> >> you.
>> >> >>
>> >> >> Gabor
>> >> >>
>> >> >> > Any help is appreciated.
>> >> >> >
>> >> >> > Best,
>> >> >> >
>> >> >> > Thiago
>> >> >> >
>> >> >> >
>> >> >> > _______________________________________________
>> >> >> > igraph-help mailing list
>> >> >> > address@hidden
>> >> >> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Gabor Csardi <address@hidden>     UNIL DGM
>> >> >>
>> >> >>
>> >> >> _______________________________________________
>> >> >> igraph-help mailing list
>> >> >> address@hidden
>> >> >> http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > _______________________________________________
>> >> > igraph-help mailing list
>> >> > address@hidden
>> >> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Gabor Csardi <address@hidden>     UNIL DGM
>> >>
>> >>
>> >> _______________________________________________
>> >> igraph-help mailing list
>> >> address@hidden
>> >> http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > igraph-help mailing list
>> > address@hidden
>> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>>
>>
>>
>> --
>> Gabor Csardi <address@hidden>     UNIL DGM
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
>
> --
> =================================
> Thiago Motta Venancio, M.Sc., PhD
> http://tmvenancio.googlepages.com
> =================================
>
> _______________________________________________
> 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]