Ok, what I did after I wrote the email is change my graph to
ListenableDirectedWeightedGraph and then i changed the constructor to
this:
public MyGraph() {
super(DefaultWeightedEdge.class);
indexer = new DirectedNeighborIndex<MyVertex, DefaultWeightedEdge>(this);
addGraphListener(indexer);
}
Then i implemented two methods:
public Set<MyVertex> successorsOf(MyVertex vertex) {
return indexer.successorOf(vertex);
}
public Set<MyVertex> precedessorsOf(MyVertex vertex){
return indexer.precedessorsOf(vertex);
}
I just want to understand if this is the correct thing or if you have
any furthers suggestion for speed optimization for local neighborhood
analysis.
TIA
/CM
On Wed, May 6, 2009 at 8:09 PM, John V. Sichi <js...@gm...> wrote:
> Claudio Martella wrote:
>>
>> I'm implementing a few algorithms that make extensive use of local
>> neighborhoods of Vertexes. Therefore I'd like to use
>> DirectedNeighborIndex class to speed up the computation. At the moment
>> I've extended SimpleDirectedWeightedGraph and added the methods
>> outgoingVertexesOf(V) and incomingVertexesOf(V), both cycling over the
>> results of outgoingEdgesOf() and incomingEdgesOf(). What I'm trying to
>> understand is re-implementing these outgoingVertexesOf() and
>> incomingVertexesOf() with calls to predecessorOf() and successorOf()
>> of DirectedNeighborhorIndex is the smartest way to optimize my code.
>> My second question, connected to the first one, is if it's possible,
>> if it's not already been used, to ask the graph to cache the calls
>> internally for some computation.
>
> I don't understand. The DirectedNeighborIndex javadoc explains that you are
> supposed to create the index and then add it as a listener to the graph; you
> don't need to modify the graph itself. The caching already happens inside
> of DirectedNeighborIndex.
>
> JVS
>
--
Claudio Martella
cla...@gm...
|