igraph-help
[Top][All Lists]
Advanced

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

[igraph] Re: Decompose a graph into connected components


From: Dr Karl
Subject: [igraph] Re: Decompose a graph into connected components
Date: Wed, 28 Apr 2010 07:53:23 -0700 (PDT)
User-agent: G2/1.0

Hi,

> You mean vertices.

    Yes, I mean vertices, sorry.

> Something is not clear to me. Why do you keep vertex attributes in
> separate vectors if you already added them to the graph?

I build a vector of edges and the corresponding attributes BEFORE
actually creating the igraph_t, like this

(...)
VECTOR(mailIds)[numMailId] = node.mail_id;
VECTOR(userIds)[numMailId] = node.author_id;
VECTOR(numRead)[numMailId] = node.numRead;
(...)

then, i create the graph

igraph_create(&g, &edges, numMailId, IGRAPH_DIRECTED);

and in another class, where I'm about to write the graphml file, I set
the attributes

SETVANV(g, "d8", &mailIds);
SETVANV(g, "d9", &userIds);
SETVANV(g, "d10", &numRead);

etc

By your answer I learn that it is better to call igraph_decompose()
AFTER setting the attributes, but if I have this code
to get connected components with at least 2 vertices

igraph_vector_ptr_t complist;
igraph_vector_ptr_init(&complist, 0);
igraph_decompose(&g, &complist, IGRAPH_WEAK, -1, 2);

I guess that complist holds a vector of pointers to igraph_vector_t?
Or does it hold a vector of pointers to igraph_t?
I mean, is it a vector to graph structures or a vector of vectors of
edges to build a graph?

Thank you.

Best regards

On 28 abr, 16:32, Gábor Csárdi <address@hidden> wrote:
> Hi,
>
>
>
>
>
> On Wed, Apr 28, 2010 at 4:22 PM, Dr Karl <address@hidden> wrote:
> > Hi,
>
> >   I'm building discussion trees from raw message logs data. The fact
> > is that for any given mailbox (forum), there are a number of
> > discussions. I need to separate each discussion in a different graph,
> > but at this momenty I create a graph with all the discussions (even
> > the isolated messages with no response).
>
> > In order to separate the discussions, at first I thought of coding a
> > recursive function which would iterate over each node, find the
> > neighbors of the node and so on, to find connected components, but
> > then I realized of the existence of the igraph_decompose() function,
> > which hopefully would save me some work.
> > I looked in the /examples directory and found igraph_decompose.c
>
> > With that function I can easily get a vector of pointers to vectors of
> > edges
>
> You mean vertices.
>
> > to build a graph for each discussion, just what I need, but I am
> > also using vertex attributes and edge attributes to write on the
> > graphml the mailId, senderId, and other metrics and data. For that
> > purpose I'm using the macros
> > SETVANV, and their kind.
>
> > The problem is that the resulting graphs after invoking the
> > igraph_decompose() function have diferent ids for every vertex, which
> > means that the vectors where I store the additional attributes are now
> > worthless,
>
> Something is not clear to me. Why do you keep vertex attributes in
> separate vectors if you already added them to the graph?
>
> > because I don't have a way to correlate every new vertex id
> > in the separate graphs with the previous vertex id with the full graph
> > with multiple connected components.
>
> igraph_decompose() keeps vertex attributes, so I don't see what is the
> problem here. I mean, you certainly have a problem if you keep your
> attributes in separate vectors, independent of the graph. But this is
> the whole point of having vertex attributes in igraph. You add them to
> the graph (e.g. with SETVANV) and then igraph takes care about them if
> the structure changes.
>
> Alternatively, you can keep your attributes in separate vectors and
> add only a (numeric of textual) vertex id to the graph as vertex
> attribute. Then you can query this vertex attribute after calling
> igraph_decompose on the graph, to follow the vertices.
>
> Best,
> Gabor
>
> [...]
> --
> Gabor Csardi <address@hidden>     UNIL DGM
>
> _______________________________________________
> igraph-help mailing list
> address@hidden://lists.nongnu.org/mailman/listinfo/igraph-help
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Network analysis with igraph" group.
> To post to this group, send email to address@hidden
> To unsubscribe from this group, send email to address@hidden
> For more options, visit this group 
> athttp://groups.google.com/group/network-analysis-with-igraph?hl=en.




reply via email to

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