a question about graph in R
2
0
Entering edit mode
jiabao xu ▴ 50
@jiabao-xu-2773
Last seen 9.7 years ago
hello,everyone: I have two graphs: G1(V,E) ,G2(V2,E2) (V2∈V,E2∈E),how to got the G(V1,E1) ,G1∪G2=G,V1∪V2=V,E1∪E2=E. THANKS FOR YOUR REPLIES! [[alternative HTML version deleted]]
• 666 views
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 9.7 years ago
Hi Jiabao, On 11/20/09 11:26 PM, jiabao xu wrote: > hello,everyone: > I have two graphs: G1(V,E) ,G2(V2,E2) (V2?V,E2?E),how to got the G(V1,E1) > ,G1?G2=G,V1?V2=V,E1?E2=E. The graph package has intersection() and union() functions that may give you what you want. If not, perhaps you can give a more detailed example for what you want. In particular, I'm not sure I understand your notation. Looks to me like you have defined G2 such that V2 is a subset of V and E2 a subset of E and G1 is (V, E). So then union(G1, G2) is just G1? + seth
ADD COMMENT
0
Entering edit mode
Seth Falcon ★ 7.4k
@seth-falcon-992
Last seen 9.7 years ago
Hi, [replying on the list] On 11/22/09 12:58 AM, jiabao xu wrote: > Hi Seth Falcon, > thanks for your reply .G1 and G2 are parts of G.and union(G1,G2) is > G,If i know the G and G2 ,how to get G1.I am sorry for that i didn't > describle clear in the last email. Hmm, I'm still a bit confused. Do you know that G1 and G2 are disjoint? I don't think there is currently a set difference type operations in the graph package which might be what you want. You can find the nodes as: g1_nodes = setdiff(nodes(G), nodes(G2)) # these will be the G1 nodes Then perhaps you can just do subGraph(G, g1_nodes) Hope that helps some. + seth > > On Sun, Nov 22, 2009 at 12:11 PM, Seth Falcon <sfalcon at="" fhcrc.org=""> <mailto:sfalcon at="" fhcrc.org="">> wrote: > > Hi Jiabao, > > > On 11/20/09 11:26 PM, jiabao xu wrote: > > hello,everyone: > I have two graphs: G1(V,E) ,G2(V2,E2) (V2?V,E2?E),how to got the > G(V1,E1) > ,G1?G2=G,V1?V2=V,E1?E2=E. > > > The graph package has intersection() and union() functions that may > give you what you want. > > If not, perhaps you can give a more detailed example for what you > want. In particular, I'm not sure I understand your notation. > Looks to me like you have defined G2 such that V2 is a subset of V > and E2 a subset of E and G1 is (V, E). So then union(G1, G2) is > just G1? > > + seth > > -- Seth Falcon Program in Computational Biology | Fred Hutchinson Cancer Research Center
ADD COMMENT
0
Entering edit mode
Hi, On Nov 23, 2009, at 7:53 PM, Seth Falcon wrote: > Hi, > > [replying on the list] > > On 11/22/09 12:58 AM, jiabao xu wrote: >> Hi Seth Falcon, >> thanks for your reply .G1 and G2 are parts of G.and union(G1,G2) is >> G,If i know the G and G2 ,how to get G1.I am sorry for that i didn't >> describle clear in the last email. You might want to look at the igraph package. It has a graph.difference function, which sounds like what you might be looking for: "graph.difference creates the difference of two graphs. Only edges present in the first graph but not in the second will be be included in the new graph." -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact
ADD REPLY

Login before adding your answer.

Traffic: 719 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6