Re: [jgrapht-users] getVertex(Object o)
Brought to you by:
barak_naveh,
perfecthash
From: John V. S. <js...@gm...> - 2009-04-07 21:14:28
|
Your mission, should you choose to accept it, is to get Sun (IBM?) to change java.util.Set to allow you to "look up" an object already in the set. Good luck. JGraphT strives to follow the patterns set by java.util. For cases like this, I usually take the approach you mention of maintaining my own HashMap outside of the graph (in an encapsulating class). If someone wanted to contributed something like a generic "KeyedGraph", that would be fine, but I think we should leave the existing interfaces alone. JVS Claudio Martella wrote: > Hello to the list members. > > I write for a topic that looks kind of hot in here: the > Graph.getVertex() method. > I'm using a SimpleDirectedWeightedGraph ecl to represent words with > my own WordNode class and their relationships (with a > DefaultWeightedEdge). Each graph vertex (a word for me) has a payload > for some statistics (i.e. the number of occurences in the > document/corpus). > > While parsing the document ( or while the application is running ) i > want to get access to the node to read its data. I've overidden the > .equals() for my WordNode class, so that it actually checks the > WordNode.getWord() - String, so the idea is to do a > graph.getVertex(new WordNode("whatever")).getOccurences() without > the need to hold all the vertexes in another datastructure (like a > HashMap), or without surfing the expensive graph.vertexSet(). > AFAIK, this is not possible in jgrapht. I don't actually want the > getVertex() to work for reference-equality, but for my value-equality > through the equals() "interface". > > Any suggestions? > > TIA > > Claudio Martella > |