Re: [jgrapht-users] Getting all connected sets of a graph as graphs
Brought to you by:
barak_naveh,
perfecthash
From: John S. <js...@gm...> - 2011-04-26 05:26:22
|
Does your ProteinGraph add anything interesting? If not, you might consider discarding it and just using the out-of-the-box classes directly. If you need it for some reason, then either do what you said at the end to make copies of the subgraphs (using Graphs.addGraph), or else make ProteinGraph an interface and create subclasses for extending SimpleGraph and UndirectedSubgraph. JVS On Mon, Apr 25, 2011 at 4:00 AM, Tim Jesussek <ts...@rc...> wrote: > > Hi list, > > I'm new to jgrapht and I'm using it to model protein graphs. What I > need to do is split a graph G into multiple graphs, each of which should > represent a connected set of G. I have found the ConnectivityInspector > class and its connectedSets() method, but I'm not sure on how to turn > the edge set it returns into a new graph. Can anybody tell me how to do > that? > > Some more details on what I've done so far follow: I have written a > ProteinGraph class that extends SimpleGraph<V, E> and implements > UndirectedGraph<V, E>. I have also written a LabeledEdge class that > extends DefaultEdge. Both of this shouldn't make much of a difference I > guess. Here is my code so far: > > > // Creates a ProteinGraph from the connectivity matrix of all > super-secondary structures of a protein chain > ProteinGraph<SSE, LabeledEdge> g = chainCM.toJGraph(); > > // Get all connected sets > ConnectivityInspector<SSE, LabeledEdge> ci = new > ConnectivityInspector<SSE, LabeledEdge>(g); > List<Set<SSE>> conSets = ci.connectedSets(); > > // Create graphs out of the connected sets > for(Integer j = 0; j < conSets.size(); j++) { > > // I can do this... > UndirectedSubgraph<SSE, LabeledEdge> subGraph = new > UndirectedSubgraph<SSE, LabeledEdge>(g, conSets.get(j), null); > > // ... but I would like to do something like this: > ProteinGraph<SSE, LabeledEdge> psg = new UndirectedSubgraph<SSE, > LabeledEdge>(g, conSets.get(j), null); > // or > ProteinGraph<SSE, LabeledEdge> psg = subGraph.toGraph(); > } > > > Using that code, my question could also be formulated as 'How can I > turn a UndirectedSubgraph into a new Graph of a certain type (my > ProteinGraph class, in this case). Is there any way to do this? Or > should I write a new constructor for ProteinGraph that uses the SubGraph > to construct the ProteinGraph based on the vertix set and edge set in > the subgraph? > > Thanks for any hints, > > > -- > Tim > > ------------------------------------------------------------------------------ > Fulfilling the Lean Software Promise > Lean software platforms are now widely adopted and the benefits have been > demonstrated beyond question. Learn why your peers are replacing JEE > containers with lightweight application servers - and what you can gain > from the move. http://p.sf.net/sfu/vmware-sfemails > _______________________________________________ > jgrapht-users mailing list > jgr...@li... > https://lists.sourceforge.net/lists/listinfo/jgrapht-users > |