igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Any examples of "overlaid" graphs?


From: Gábor Csárdi
Subject: Re: [igraph] Any examples of "overlaid" graphs?
Date: Tue, 12 May 2009 20:15:46 +0200

Paul,

one way would be to have an edge attribute that gives the type of the
relationship. E.g. if you want to have the data in a text file, then
arrange it like this:

from         to         type
Alice        Bob      friend
Bob         Cecil    colleague
Bob         Cecil    friend
...

This way you can read it in into R easily with 'read.table()',
possibly filter it, and then create a graph from it with
'graph.data.frame()'. Filtering is needed e.g. if you want to
calculate structural properties and want to include only one type of
edges, or a subset of edges.

For plotting you don't have to filter, just include all edges and then
select the ones that you want to plot with the 'lty' edge graphics
parameter, e.g.

E(g)$lty <- ifelse( E(g)$type=="friend", 1, 0 )
plot(g, ...)

will only plot the "friend" edges (0 means no edges are plotted), while

E(g)$lty <- ifelse( E(g)$type=="colleague", 1, 0 )
plot(g, ...)

will only plot the "colleague" edges.

You can plot many graphs on top of each other by giving 'add=TRUE' to
plot(). See http://igraph.sourceforge.net/screenshots2.html#3 for an
example.

Btw. tkplot() cannot be used for plotting many graphs on the same
figure, but you can use it to fine tune the node positions, store them
in a matrix with 'tkplot.getcoords()' and then giving them to
'plot()'.

As for the subgraphs, assign an id to the vertices, just numbers if
you don't have other ids:
V(g)$name <- seq(vcount(g))
and these are kept by 'subgraph()'.

Please don't hesitate to ask if you have more questions,
Best, G.

On Tue, May 12, 2009 at 7:41 PM, Paul Johnson <address@hidden> wrote:
> I'd like to make a drawing that has objects positioned with directed
> arrows, and then load a new dataset that can be used to add "different
> arrows" between the objects.  For example, I could draw a family tree
> with fathers, mothers, and children,  and then "superimpose" a contact
> network to show which agents talk to each other on the phone.
>
> I've been using igraph's C library to do some analysis and generate
> the edge file, and then I bring that into R for interactive analysis.
> This works pretty well, although I've just scratched at the surface of
> igraph's power so far.
>
> I'm having a little trouble figuring out how to organize the data in
> the edge files so that this will be possible to overlay the 2 sets of
> edges.  Does anybody have a working example?
>
> In the project, there are lots of networks, and I've been using
> igraph's subgraph function to collect up a subset of 20  vertices for
> illustration.  In tkplot, the vertex numbers are always re-assigned
> from 1 to 20, and so I'm somewhat unsure about how to best create the
> text file with the edges in it.
>
> If you can advise me, I would appreciate it.
>
> --
> Paul E. Johnson
> Professor, Political Science
> 1541 Lilac Lane, Room 504
> University of Kansas
>
>
> _______________________________________________
> 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]