2

Im building a graph with over 90000 edges:

DefaultDirectedGraph graph = ...
graph.addVertex(keyFrom);
graph.addVertex(keyTo);
graph.addEdge(keyFrom, keyTo);

With new version I have following results:

  • BUILD_GRAPH took 13596 ms Number of edges: 90469
  • BUILD_GRAPH took 14354 ms Number of edges: 94309
  • BUILD_GRAPH took 6647 ms Number of edges: 90465

With the old Version I have following results::

  • BUILD_GRAPH took 5081 ms Number of edges: 90469
  • BUILD_GRAPH took 3949 ms Number of edges: 94309
  • BUILD_GRAPH took 4351 ms Number of edges: 90466

Profiler told me that this code is slow in the lib:

UniformIntrusiveEdgesSpecifics:
 return edgeMap.putIfAbsent(e, intrusiveEdge) == null;

I tried to improve the hashCode of vertex. But it does not help. I would like to switch to the new version of the lib. But performance is an issue. Any idea, why the new version of the lib is slower?

  • 1
    Could you post this one as an issue on our github issue tracker: https://github.com/jgrapht/jgrapht/issues This might be a bit challenging to resolve in a Q&A format on stackoverflow. A lot of changes were made between 0.8.2 and 1.3.0. Typically, the default graphs in 1.3.0 take more memory space to construct, but most common graph queries run faster. We would need some more information. – Joris Kinable Feb 04 '20 at 05:21

1 Answers1

0

Following I found out:

  • The graph has not 90 000 edges big but it has 3 Mio edges! Only with big graphs you can observe a difference in performance!
  • If override the containsEdge Method of the Graph than performance is three times better on the older version than on the new version

    new DefaultDirectedGraph<GraphNode,StandardFieldConnKeyEdge>(StandardFieldConnKeyEdge.class) {

        @Override
        public StandardFieldConnKeyEdge addEdge(final GraphNode sourceVertex, final GraphNode targetVertex) {
            return super.addEdge(sourceVertex, targetVertex);
    
        }
    
        @Override
        public boolean containsEdge(final GraphNode sourceVertex, final GraphNode targetVertex) {
            return false;
        }
    
    };
    

I have a eclipse project which shows this issue!