From: Joshua O'M. <jos...@gm...> - 2014-07-02 16:49:19
|
Debra: More or less in order... Splitting the data into two separate graphs seems reasonable. I would clarify that you don't put "copies" of the nodes in the new graph (in the sense that you are creating new objects) but references to the same objects. The way that you're describing what you've been doing suggests to me that you're somewhat confused between (a) the data model (i.e., representation in terms of data structures) (b) the visualization of that data You can certainly create a visualization that displays more than one graph. There is sample code in the distribution that gives examples of doing this. Some technical details: * You can declare your graph as Graph<Women, String> (or if you have an relation object that represents the relation, Graph<Women, Friendship> and Graph<Women, History>) rather than extracting the ID from your Women object. That way it's more clear what the Graph represents, and you have all the information in the original object in the same place. (Nor does it take up more space--the opposite, in fact, since you're not creating a new Integer object for each vertex.) * The easiest way to add each of the Women objects to both graphs is just to add them both in the same loop, as below. (In any case, addVertex() takes a single vertex--in this case, an Integer--and calling it on a Collection<Integer> won't work.) static Graph<Integer, String> g; static Graph<Integer, String> g2; for (Women aWoman : GaleShapely2.womenList) { g.addVertex(aWoman); g2.addVertex(aWoman); } Hope this helps. Joshua PS: FYI, you sent this to the owner of the jung-support list rather than to the list itself; I've taken the liberty of redirecting my response. Also, support questions are best sent to StackOverflow these days; that's where most of the questions relating to JUNG are being asked and answered. On Wed, Jul 2, 2014 at 5:53 AM, Debra Hevenstone <dhe...@gm...> wrote: > Hi Everyone, > > I have a program where I was running a simulation where I created one > network with two types of edges - first friendship edges, and then, once > friendship edges were generated, I ran a matching algorithm (Gale Shapely) > with information limited to one's local network, and saved those new edges > onto the original graph, just labeling them differently. > > I would like split this into 2 graphs: a friendship graph and a > relationship-history graph. I understand I can create a separate graph and > just put copies of the nodes in the new graph. > > My first graph was created in SimpleGraphView.java and in the constructor > I added all the vertices. > > My question is whether I can create the second graph (just the vertices, > before edges are created) in the same file, directly after the first graph. > It seems like it might be problematic in terms of visualization. On the > other hand, if I can't create the second graph there, I'm not sure where I > would create it. > > A shortened version of the original code is something like this: > > public class SimpleGraphView { > > static Graph<Integer, String> g; > > for (Women aWoman : GaleShapely2.womenList) { > > g.addVertex(aWoman.getID()); > > } > > } > > > I imagine the new code would be something like this: > > > public class SimpleGraphView { > > static Graph<Integer, String> g; > > static Graph<Integer, String> g2; > > for (Women aWoman : GaleShapely2.womenList) { > > g.addVertex(aWoman.getID()); > > } > > g2.addVertex(g.getVertices()); > > } > > Would that work? > -- jos...@gm.........sites.google.com/site/joshuaomadadhain/ Joshua O'Madadhain: Information Scientist, Musician, Philosopher-At-Tall It's that moment of dawning comprehension that I live for. -- Bill Watterson My opinions are too rational and insightful to be those of any organization. |