Hi Gabor, my question is: dose "supgraph.edges" function changes nodes indices even when we keep vertices (delete.vertices = FALSE )? I try it and it didn't but could I generalize it or its behavior is like "induced.subgraph"?
Peidong chen, thanks for the "function" but as Gabor said it is not different from "induced.subgraph" function and it works with indices as well if we want to change that, I guess we should work with V(g)$name instead. this defined function is not the function I am looking for and I rather want to delete some edges from the graph and keep isolated edges so the vertices are the same. mygraph<-subgraph.edges(graph,which(E(mygraph)$weight>0),delete.vertices = FALSE) Thank you in advance, Fatemeh On Mon, May 4, 2015 at 6:12 PM, Gábor Csárdi <[email protected]> wrote: > How is this different from just calling induced.subgraph()? (Apart from > being slower for small subgraphs of large graphs.) > > > g <- graph.ring(10) > > V(g)$name <- LETTERS[1:10] > > get.edgelist(get_sub_graph(6:10, g), names = FALSE) > [,1] [,2] > [1,] 1 2 > [2,] 2 3 > [3,] 3 4 > [4,] 4 5 > > get.edgelist(induced.subgraph(g, 6:10), names = FALSE) > [,1] [,2] > [1,] 1 2 > [2,] 2 3 > [3,] 3 4 > [4,] 4 5 > > G. > > On Sun, May 3, 2015 at 5:47 PM, Peidong Chen <[email protected]> wrote: > >> I think it is better to define functions by our own. >> >> get_sub_graph <- function(subGraphNodes,g) >> { >> nonSubGraphNodes <- which(!((1:vcount(g)) %in% subGraphNodes)) >> subGraph <- delete.vertices(g , nonSubGraphNodes) >> subGraph >> } >> >> 2015-05-03 14:24 GMT-07:00 Fatemeh a <[email protected]>: >> >> >>> thanks for your reply. >>> this question raised because as you mention "induced.subgraph"actually >>> dose that , but I checked it when we keep delete.vertices = FALSE and with >>> one small example it dosen't change that, but i can't be sure and >>> generalized it, so what about when we keep the vertices ? >>> >>> On Mon, May 4, 2015 at 1:39 AM, Peidong Chen <[email protected]> >>> wrote: >>> >>>> I think it changes nodes indices, because like "induced.subgraph" >>>> function creates a totally new indices different from the original graph >>>> >>>> 2015-05-03 14:07 GMT-07:00 Fatemeh a <[email protected]>: >>>> >>>>> Hi all, >>>>> >>>>> I have a question regards subgraph, dose supgraph.edges function >>>>> changes nodes indices? >>>>> >>>>> thank you in advance, >>>>> Fatemeh >>>>> >>>>> -- >>>>> regards >>>>> F..A >>>>> >>>>> _______________________________________________ >>>>> 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 >>>> >>>> >>> >>> >>> -- >>> regards >>> F..A >>> >>> _______________________________________________ >>> 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 >> >> > -- regards F..A
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
