[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] igraph class functions
From: |
Peter McMahan |
Subject: |
[igraph] igraph class functions |
Date: |
Tue, 17 Apr 2007 22:08:58 -0500 |
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] igraph class functions,
Peter McMahan <=