Closed gaborcsardi closed 9 years ago
Some random ideas:
+
disjoint union of graphs (this is partially implemented already, but it does union for named graphs, which is error-prone and not what I want ultimately. +
should be disjoint union, always.-
difference of graphs.|
union of graphs (logical or operator on the adjacency matrices, so this makes sense).&
intersection of graphs, logical and operator on the adjacency matrices, so this makes sense.!
complementer graph, maybe, although this is probably not often used, the the complementer of a sparse graph is dense.^
graph power? Maybe./
quotient graph (=contract.vertices), maybe. This could work with any kind of vertex groupings, e.g. the result of community finding algorithms.*
maybe graph product, but there is a bunch of them, http://en.wikipedia.org/wiki/Graph_product, so probably we don't want to choose and just reserve *
for somethinf else%%
could be used for time slicing in time-dependent graphs, although
@
would be more readable, but that seems to be impossible.%/%
???%
operator we want to define.Comparison operators:
==
isomorphism? exact equality for named graphs? exact equality in general?!=
opposite of ==
, whatever that is.<
subgraph (strict)?<=
subgraph? Maybe not.>=
subgraph? Maybe not.>
subgraph?Alternatively <
an >
could be used for time slicing as well, e.g.
G < 1990
can be the graph before (at, really) 1990, and
G > 1980
can be the graph after 1980, and
G < 1990 > 1980
is the intersection of the two. Somewhat cumbersome and not very readable.
How about using ~
for time slicing? This could be good, actually, although
~
is not generic, so we'll need to shadow the original definition:
`~` <- function(class, slot) UseMethod("~")
`~.default` <- function(class, slot) base::`~`(class, slot)
`~.igraph` <- function(graph, at) {
print("foo!"); print(substitute(at))
}
G ~ 100
This works for igraph, but unfortunately this seems to break functions that work with formulas,
e.g. lm()
, which is a no-go.
ego()
to return an ego network, graph.neighborhood with order=1, essentially. Not really an operator, just writing it down, so that I don't forget it.
&
could be used to create subgraphs: G & edges(...)
keeps only the edges listed, it can be abbreviated as G & E()
. It should be flexible enough to select edges with specific
attributes, etc. E.g.
G & E(weight > 1)
G & E(color == "red")
G & vertices(...)
keeps only the vertices listed (induced subgraph)
it can be abbreviated as G & V()
. It handles attributes as well:
G & V(degree(G) > 1)
or even
G & V(degree > 1)
in which case it notices that degree
is a function, so it calls it with the
graph as the argument. This could be done for the already existing
E()
and V()
functions as well.
On the other hand people can just use https://github.com/smbache/magrittr, which works well with igraph functions in most cases, and is very readable.
igraph operators do not play that well with it, because %>%
has a higher precedence than +
, etc. so you need to write parens, e.g.
(graph.ring(10) + 5) %>% plot()
which might not be as clear as
graph.ring(10) %>%
add(5) %>%
plot()
Not really needed, so closing now.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
From @gaborcsardi on May 9, 2014 14:5
For creating subgraphs (https://github.com/igraph/xdata-igraph/issues/39) and more.
Copied from original issue: igraph/igraph#614