igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph class functions


From: Gabor Csardi
Subject: Re: [igraph] igraph class functions
Date: Wed, 18 Apr 2007 14:12:50 +0200
User-agent: Mutt/1.5.12-2006-07-14

Peter,

you're completely right, i'll change this in a minute.
Thanks for the suggestion.

Best,
Gabor

On Tue, Apr 17, 2007 at 10:08:58PM -0500, Peter McMahan wrote:
> Hi,
> I noticed an inconsistency in the way that igraph functions handle  
> classes. Most functions check the input graph with a call to is.igraph:
> function (graph)
> {
>     res <- (class(graph) == "igraph")
>     res
> }
> 
> The problem is that in R, class inheritence is handled by classes of  
> length greater than 1. So if I'm trying to make a new class called  
> "mygraph" that extends "igraph", then I'll set my class attribute to  
> be c("mygraph","igraph"). Then if I call plot() it will look for  
> plot.mygraph() and if it doesn't find it will revert to plot.igraph 
> (). With the current class catching, this will then thow a warning  
> and an error.
> 
> May i suggest the following change?:
> 
> is.igraph <- function(graph){
>     res <- ("igraph" %in% class(graph))
>     res
> }
> 
> With this definition objects for which "igraph" is not the first  
> class will still be passable to igraph-specific functions.
> 
> Thanks,
> Peter McMahan
> 
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

-- 
Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK




reply via email to

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