Hi, plot() uses the 'x' and 'y' vertex attributes if they are present, e.g:
library(igraph) g <- graph.ring(10) V(g)$x <- 1:10 V(g)$y <- rep(1:2, each=5) plot(g) See ?layout.auto, which is the default layout. Gabor On Tue, Mar 11, 2014 at 6:05 AM, Tamás Nepusz <[email protected]> wrote: > Hi, > > Your request makes perfect sense but there are a few corner cases that > should be taken into consideration: > > 1) layouts are not "associated" to the graph they are created from so they > cannot "detect" when the graph is subsetted > 2) even if layouts were associated to a graph, it is entirely possible to > work with two separate layouts for the same graph, in which case it would > be unclear which layout is the one that should be assigned to the induced > subgraph. > > Actually, you can also assign a layout to a graph by setting the "layout" > attribute of the graph as follows: > > g$layout <- layout.fruchterman.reingold(g) > > I think that it would be useful if induced.subgraph() could also update > the $layout attribute of the subgraph based on the $layout attribute of the > original graph; I leave it up to Gabor to decide whether he wants to > implement it in the R interface or not. > > -- > T. > > ------------------------------------------------------ > From: David Edwards [email protected] > Reply: David Edwards [email protected] > Date: 11 March 2014 at 10:36:41 > To: Tamás Nepusz [email protected] > Subject: RE: [igraph] Derived layouts for subgraphs > > > Hi, > > > > Thanks for this. No, its not because its a difficult problem for a user > to deal with, I just > > thought that it would be nice if it was default. > > > > Regards > > David > > > > > > > > ________________________________________ > > From: Tamás Nepusz [[email protected]] > > Sent: 11 March 2014 10:20 > > To: David Edwards; Help for igraph users > > Subject: Re: [igraph] Derived layouts for subgraphs > > > > Hi, > > > > The layout of a graph is simply a matrix with n rows and 2 columns, so > one thing that you can > > do is to store the layout separately and then subset the matrix for the > individual subgraphs; > > e.g.: > > > > layout <- layout.fruchterman.reingold(g) > > subg <- induced.subgraph(g, vids) > > sublayout <- layout[vids,] > > plot(subg, layout=sublayout) > > > > Another option is to store the X and Y coordinates of the layout in > vertex attributes named > > "x" and "y", because these are used automatically by igraph when you > plot a graph: > > > > layout <- layout.fruchterman.reingold(g) > > V(g)$x <- layout[,1] > > V(g)$y <- layout[,2] > > subg <- induced.subgraph(g, vids) > > plot(subg) > > > > -- > > T. > > > > ------------------------------------------------------ > > From: David Edwards [email protected] > > Reply: Help for igraph users [email protected] > > Date: 11 March 2014 at 08:24:21 > > To: [email protected] [email protected] > > Subject: [igraph] Derived layouts for subgraphs > > > > > Hi > > > when the layout of graph G is set, could > > > induced.subgraph(G, vids) (for some vector vids of vertex ids) > > > inherit that layout? (it seems to inherit other attributes). > > > Best regards > > > David > > > ________________________________________ > > > From: > > > [email protected][igraph-help-bounces+david.edwards= > [email protected]] > > > on behalf of [email protected] [ > [email protected]] > > > Sent: 10 March 2014 17:01 > > > To: [email protected] > > > Subject: igraph-help Digest, Vol 92, Issue 6 > > > > > > Send igraph-help mailing list submissions to > > > [email protected] > > > > > > To subscribe or unsubscribe via the World Wide Web, visit > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > or, via email, send a message with subject or body 'help' to > > > [email protected] > > > > > > You can reach the person managing the list at > > > [email protected] > > > > > > When replying, please edit your Subject line so it is more specific > > > than "Re: Contents of igraph-help digest..." > > > > > > > > > Today's Topics: > > > > > > 1. Re: plotting graphs with edges of various length (G?bor Cs?rdi) > > > 2. Re: plotting graphs with edges of various length (Tam?s Nepusz) > > > 3. Re: plotting graphs with edges of various length (aschmid1) > > > 4. Re: plotting graphs with edges of various length (G?bor Cs?rdi) > > > 5. Installation error (David Gelvez Alvarez) > > > 6. Re: Installation error (G?bor Cs?rdi) > > > 7. Re: Installation error (Tam?s Nepusz) > > > 8. Re: Installation error (Tam?s Nepusz) > > > 9. Re: Installation error (David Gelvez Alvarez) > > > > > > > > > ---------------------------------------------------------------------- > > > > > > Message: 1 > > > Date: Sun, 9 Mar 2014 14:38:47 -0400 > > > From: G?bor Cs?rdi > > > To: Help for igraph users > > > Subject: Re: [igraph] plotting graphs with edges of various length > > > Message-ID: > > > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > Hi, maybe I am missing something, but what is your question? > > > > > > Why some red edges are shorter? For that we would need a reproducible > > > example. > > > > > > Why the "weight" and/or "length" attribute is not used automatically? > Or > > > something else? > > > > > > Gabor > > > > > > > > > On Sat, Mar 8, 2014 at 10:37 PM, aschmid1 wrote: > > > > > > > Hi, > > > > I thought that the commands > > > > gm<-set.edge.attribute(gm, "weight", index=E(gm), value=weights) > > > > gm<-set.edge.attribute(gm, "length", index=E(gm), value=weights) > > > > ensure that plot(gm) yields the edge lengths corresponding to the > values > > > > of vector weights. It seems not the case. I attach the graph in > which blue > > > > edges have weights < 1 and red edges have weights >1. However, some > red > > > > edges look shorter than some blue edges. > > > > Thanks much, Alec > > > > _______________________________________________ > > > > igraph-help mailing list > > > > [email protected] > > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > > > > > -------------- next part -------------- > > > An HTML attachment was scrubbed... > > > URL: > > > > > > ------------------------------ > > > > > > Message: 2 > > > Date: Sun, 9 Mar 2014 20:32:15 +0100 > > > From: Tam?s Nepusz > > > To: Help for igraph users , aschmid1 > > > > > > Subject: Re: [igraph] plotting graphs with edges of various length > > > Message-ID: > > > Content-Type: text/plain; charset="utf-8" > > > > > > > I thought that the commands > > > > gm<-set.edge.attribute(gm, "weight", index=E(gm), value=weights) > > > > gm<-set.edge.attribute(gm, "length", index=E(gm), value=weights) > > > > ensure that plot(gm) yields the edge lengths corresponding to the > values > > > > of vector weights. > > > No, it doesn?t. *Some* layout algorithms *might* take into account the > weights of the > > > edges to *some* extent (i.e. they would *try* to ensure that edges > with larger weights > > > end up being shorter than edges with smaller weights), but there is no > layout algorithm > > > that would guarantee that the lengths you specify are satisfied > exactly. The main reason > > > is that most of the length combinations are impossible to satisfy in > the 2D plane; for > > > instance, it is impossible to plot a full graph of size 4 if we want > every single edge to > > > be of length 1 (and there are infinitely many examples for this). > > > > > > As far as I know, the Fruchterman-Reingold layout algorithm (see > layout.fruchterman.reingold) > > > is the only one in igraph that supports weights; see? > http://igraph.sourceforge.net/doc/R/layout.html > > > . But even for the Fruchterman-Reingold algorithm, the only thing that > the weights > > do > > > is that they make the attraction forces between the endpoints of the > edges proportional > > > to the weight of the edge. > > > > > > ?? > > > T. > > > > > > > > > > > > > > > > > > ------------------------------ > > > > > > Message: 3 > > > Date: Sun, 09 Mar 2014 18:05:37 -0400 > > > From: aschmid1 > > > To: Tam?s Nepusz > > > Cc: Help for igraph users > > > Subject: Re: [igraph] plotting graphs with edges of various length > > > Message-ID: <[email protected]> > > > Content-Type: text/plain; charset=UTF-8; format=flowed > > > > > > Tamas, > > > Thank you. I suspected I wanted too much from igraph. Indeed one cannot > > > draw say a triangle with arbitrary edge lengths... But then I have a > > > naive question (I'm new to graphs): how the edge attribute "length" may > > > be used (providing there is also attribute "weight")? > > > Best, Alec > > > > > > On 03/09/2014 3:32 PM, Tam?s Nepusz wrote: > > > >> I thought that the commands > > > >> gm<-set.edge.attribute(gm, "weight", index=E(gm), value=weights) > > > >> gm<-set.edge.attribute(gm, "length", index=E(gm), value=weights) > > > >> ensure that plot(gm) yields the edge lengths corresponding to the > > > >> values > > > >> of vector weights. > > > > No, it doesn?t. *Some* layout algorithms *might* take into account > the > > > > weights of the edges to *some* extent (i.e. they would *try* to > ensure > > > > that edges with larger weights end up being shorter than edges with > > > > smaller weights), but there is no layout algorithm that would > > > > guarantee that the lengths you specify are satisfied exactly. The > main > > > > reason is that most of the length combinations are impossible to > > > > satisfy in the 2D plane; for instance, it is impossible to plot a > full > > > > graph of size 4 if we want every single edge to be of length 1 (and > > > > there are infinitely many examples for this). > > > > > > > > As far as I know, the Fruchterman-Reingold layout algorithm (see > > > > layout.fruchterman.reingold) is the only one in igraph that supports > > > > weights; see?http://igraph.sourceforge.net/doc/R/layout.html . But > > > > even for the Fruchterman-Reingold algorithm, the only thing that the > > > > weights do is that they make the attraction forces between the > > > > endpoints of the edges proportional to the weight of the edge. > > > > > > > > ?? > > > > T. > > > > > > > > > > > > ------------------------------ > > > > > > Message: 4 > > > Date: Sun, 9 Mar 2014 19:01:09 -0400 > > > From: G?bor Cs?rdi > > > To: Help for igraph users > > > Cc: Tam?s Nepusz > > > Subject: Re: [igraph] plotting graphs with edges of various length > > > Message-ID: > > > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > I am not sure why you think the "length" edge attribute is used for > > > anything. It is not, AFAIK. > > > > > > G. > > > > > > > > > On Sun, Mar 9, 2014 at 6:05 PM, aschmid1 wrote: > > > > > > > Tamas, > > > > Thank you. I suspected I wanted too much from igraph. Indeed one > cannot > > > > draw say a triangle with arbitrary edge lengths... But then I have a > naive > > > > question (I'm new to graphs): how the edge attribute "length" may be > used > > > > (providing there is also attribute "weight")? > > > > Best, Alec > > > > > > > > > > > > On 03/09/2014 3:32 PM, Tam?s Nepusz wrote: > > > > > > > >> I thought that the commands > > > >>> gm<-set.edge.attribute(gm, "weight", index=E(gm), value=weights) > > > >>> gm<-set.edge.attribute(gm, "length", index=E(gm), value=weights) > > > >>> ensure that plot(gm) yields the edge lengths corresponding to the > values > > > >>> of vector weights. > > > >>> > > > >> No, it doesn't. *Some* layout algorithms *might* take into account > the > > > >> weights of the edges to *some* extent (i.e. they would *try* to > ensure > > > >> that edges with larger weights end up being shorter than edges with > > > >> smaller weights), but there is no layout algorithm that would > > > >> guarantee that the lengths you specify are satisfied exactly. The > main > > > >> reason is that most of the length combinations are impossible to > > > >> satisfy in the 2D plane; for instance, it is impossible to plot a > full > > > >> graph of size 4 if we want every single edge to be of length 1 (and > > > >> there are infinitely many examples for this). > > > >> > > > >> As far as I know, the Fruchterman-Reingold layout algorithm (see > > > >> layout.fruchterman.reingold) is the only one in igraph that supports > > > >> weights; see http://igraph.sourceforge.net/doc/R/layout.html . But > > > >> even for the Fruchterman-Reingold algorithm, the only thing that the > > > >> weights do is that they make the attraction forces between the > > > >> endpoints of the edges proportional to the weight of the edge. > > > >> > > > >> -- > > > >> T. > > > >> > > > > > > > > _______________________________________________ > > > > igraph-help mailing list > > > > [email protected] > > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > -------------- next part -------------- > > > An HTML attachment was scrubbed... > > > URL: > > > > > > ------------------------------ > > > > > > Message: 5 > > > Date: Sun, 9 Mar 2014 19:46:26 -0500 > > > From: David Gelvez Alvarez > > > To: [email protected] > > > Subject: [igraph] Installation error > > > Message-ID: > > > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > Dear all, > > > > > > Thanks a lot for your help. I'm trying to install igraph for python > but I > > > have not been able to do it. I have the Anaconda Python version. > > > > > > I downloaded the dmg for the 0.7 version and followed the dialog and > the > > > import does not work. Also, I tried to use the easy install and I get > the > > > following error: > > > > > > In file included from src/arpackobject.c:23: > > > src/arpackobject.h:27:10: fatal error: 'igraph_arpack.h' file not found > > > #include > > > ^ > > > 1 error generated. > > > error: Setup script exited with error: command 'gcc' failed with exit > > > status 1 > > > > > > Can some one give me a hand? > > > > > > Kind regards, > > > > > > David > > > -------------- next part -------------- > > > An HTML attachment was scrubbed... > > > URL: > > > > > > ------------------------------ > > > > > > Message: 6 > > > Date: Sun, 9 Mar 2014 21:15:23 -0400 > > > From: G?bor Cs?rdi > > > To: Help for igraph users > > > Subject: Re: [igraph] Installation error > > > Message-ID: > > > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > Hi, the DMG is for the system python, so it won't work with Anaconda > > > (apparently). > > > > > > If you install from source you need to install the igraph C library > first. > > > > > > Gabor > > > > > > > > > On Sun, Mar 9, 2014 at 8:46 PM, David Gelvez Alvarez > > > wrote: > > > > > > > Dear all, > > > > > > > > Thanks a lot for your help. I'm trying to install igraph for python > but I > > > > have not been able to do it. I have the Anaconda Python version. > > > > > > > > I downloaded the dmg for the 0.7 version and followed the dialog and > the > > > > import does not work. Also, I tried to use the easy install and I > get the > > > > following error: > > > > > > > > In file included from src/arpackobject.c:23: > > > > src/arpackobject.h:27:10: fatal error: 'igraph_arpack.h' file not > found > > > > #include > > > > ^ > > > > 1 error generated. > > > > error: Setup script exited with error: command 'gcc' failed with exit > > > > status 1 > > > > > > > > Can some one give me a hand? > > > > > > > > Kind regards, > > > > > > > > David > > > > > > > > _______________________________________________ > > > > igraph-help mailing list > > > > [email protected] > > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > > > > > -------------- next part -------------- > > > An HTML attachment was scrubbed... > > > URL: > > > > > > ------------------------------ > > > > > > Message: 7 > > > Date: Mon, 10 Mar 2014 11:09:12 +0100 > > > From: Tam?s Nepusz > > > To: Help for igraph users > > > Subject: Re: [igraph] Installation error > > > Message-ID: > > > Content-Type: text/plain; charset="utf-8" > > > > > > Hello, > > > > > > As Gabor has confirmed it, the DMG won?t work because it installs > igraph for the system > > > Python (that comes built-in with Mac OS X) and not Anaconda Python. > You have to compile > > > the Python module yourself. easy_installing python-igraph does not > work yet because > > > you have not downloaded and installed the C core of igraph, and the > Python interface > > depends > > > on the C core. > > > > > > Actually, I was a bit lazy as I haven?t released the 0.7 version of > the Python interface > > > yet even though the core C library is already at version 0.7. Let me > release the 0.7 version > > > first (I?ll do it today) and then you can retry with easy_install > because the installer > > > of the 0.7 version should now be smart enough to download and compile > the corresponding > > > C library as well if you have not installed it already. > > > > > > All the best, > > > -- > > > T. > > > > > > ------------------------------------------------------ > > > From:?David Gelvez Alvarez [email protected] > > > Reply:?Help for igraph users [email protected] > > > Date:?10 March 2014 at 01:47:20 > > > To:[email protected] [email protected] > > > Subject:? [igraph] Installation error > > > > > > > Dear all, > > > > > > > > Thanks a lot for your help. I'm trying to install igraph for python > but I > > > > have not been able to do it. I have the Anaconda Python version. > > > > > > > > I downloaded the dmg for the 0.7 version and followed the dialog and > the > > > > import does not work. Also, I tried to use the easy install and I > get the > > > > following error: > > > > > > > > In file included from src/arpackobject.c:23: > > > > src/arpackobject.h:27:10: fatal error: 'igraph_arpack.h' file not > found > > > > #include > > > > ^ > > > > 1 error generated. > > > > error: Setup script exited with error: command 'gcc' failed with exit > > > > status 1 > > > > > > > > Can some one give me a hand? > > > > > > > > Kind regards, > > > > > > > > David > > > > _______________________________________________ > > > > igraph-help mailing list > > > > [email protected] > > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > > > > > > > > > > > > > ------------------------------ > > > > > > Message: 8 > > > Date: Mon, 10 Mar 2014 11:20:57 +0100 > > > From: Tam?s Nepusz > > > To: Help for igraph users > > > Subject: Re: [igraph] Installation error > > > Message-ID: > > > Content-Type: text/plain; charset="utf-8" > > > > > > > Actually, I was a bit lazy as I haven?t released the 0.7 version of > the Python interface? > > > > yet even though the core C library is already at version 0.7. Let me > release the 0.7 version > > > > first (I?ll do it today) > > > Okay, it turned out to be faster than expected; the source code of the > Python interface > > > for the 0.7 version is now uploaded to the Python Package Index. I > tried ?easy_install > > > python-igraph? in a clean virtual environment on a machine where the C > core was not installed > > > and everything went fine, so please try ?easy_install python-igraph? > again and let > > > me know if it does not work with Anaconda Python. > > > > > > All the best, > > > Tamas > > > > > > > > > > > > ------------------------------ > > > > > > Message: 9 > > > Date: Mon, 10 Mar 2014 05:58:38 -0500 > > > From: David Gelvez Alvarez > > > To: Help for igraph users > > > Subject: Re: [igraph] Installation error > > > Message-ID: > > > > > > Content-Type: text/plain; charset="iso-8859-1" > > > > > > Hi All, > > > > > > Thank you for your prompt answer. I tried the easy install, but here is > > > what I get. Thanks again for your help! > > > > > > David > > > > > > *********** Log starts here > > > > > > grep: /usr/lib/libiconv.la: No such file or directory > > > sed: /usr/lib/libiconv.la: No such file or directory > > > libtool: link: `/usr/lib/libiconv.la' is not a valid libtool archive > > > make[3]: *** [libigraph.la] Error 1 > > > make[2]: *** [all] Error 2 > > > make[1]: *** [all-recursive] Error 1 > > > make: *** [all] Error 2 > > > Could not download and compile the C core of igraph. > > > > > > WARNING: we were not able to detect where igraph is installed on > > > your machine (if it is installed at all). We will use the fallback > > > library and include pathss hardcoded in setup.py and hope that the > > > C core of igraph is installed there. > > > > > > If the compilation fails and you are sure that igraph is installed > > > on your machine, adjust the following two variables in setup.py > > > accordingly and try again: > > > > > > - LIBIGRAPH_FALLBACK_INCLUDE_DIRS > > > - LIBIGRAPH_FALLBACK_LIBRARY_DIRS > > > > > > Build type: dynamic extension > > > Include path: /usr/include/igraph /usr/local/include/igraph > > > Library path: > > > Linked dynamic libraries: igraph > > > Linked static libraries: > > > Extra compiler options: > > > Extra linker options: > > > In file included from src/arpackobject.c:23: > > > src/arpackobject.h:27:10: fatal error: 'igraph_arpack.h' file not found > > > #include > > > ^ > > > 1 error generated. > > > error: Setup script exited with error: command 'gcc' failed with exit > > > status 1 > > > > > > > > > On Mon, Mar 10, 2014 at 5:20 AM, Tam?s Nepusz wrote: > > > > > > > > Actually, I was a bit lazy as I haven't released the 0.7 version > of the > > > > Python interface > > > > > yet even though the core C library is already at version 0.7. Let > me > > > > release the 0.7 version > > > > > first (I'll do it today) > > > > Okay, it turned out to be faster than expected; the source code of > the > > > > Python interface for the 0.7 version is now uploaded to the Python > Package > > > > Index. I tried "easy_install python-igraph" in a clean virtual > environment > > > > on a machine where the C core was not installed and everything went > fine, > > > > so please try "easy_install python-igraph" again and let me know if > it does > > > > not work with Anaconda Python. > > > > > > > > All the best, > > > > Tamas > > > > > > > > _______________________________________________ > > > > igraph-help mailing list > > > > [email protected] > > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > -------------- next part -------------- > > > An HTML attachment was scrubbed... > > > URL: > > > > > > ------------------------------ > > > > > > _______________________________________________ > > > igraph-help mailing list > > > [email protected] > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > > > End of igraph-help Digest, Vol 92, Issue 6 > > > ****************************************** > > > > > > _______________________________________________ > > > igraph-help mailing list > > > [email protected] > > > https://lists.nongnu.org/mailman/listinfo/igraph-help > > > > > > > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
