[Networkit] addEdge seg faults when invoked with nodes not present in the graph

Albert Cardona sapristi at gmail.com
Fri Jun 23 20:00:19 CEST 2017

Hi Henning and Matteo,

While I am not partial to any naming scheme, I have two comments to make:

1. Invoking a method "incorrectly" should not seg fault a python
program. At most, throw an exception. If the latter is not possible
for performance reasons, then these methods need to be flagged in some
way as "unsafe", as in, the user be warned that strict usage is to be
expected. Given that a method like "addEdge" is bound to be used a
lot, this issue will bite many beginner users of the library such as

2. A possible solution would be to build a "networkx" subpackage, so
to speak: a namespace implementing basic functions in the same way
that networkx does, but with networkit as the backend. Among these
there would be the constructors Graph and Digraph; their functions
add_node, add_edge; node and edge and weight lookups a-la networkx;
and some other basics that could be added incrementally. That there is
a performance cost is clear, and that should be stated in the
documentation of one such package. This package would both facilitate
the adoption of networkit and provide, for many use cases, a drop-in
replacement for networkx. Once users are in, and their networkx-styled
programs are working, upon learning that performance could increase if
they used networkit functions directly, then there's every reason and
motivation for them to do so. Note that, given the abysmal performance
of networkx, this new drop-in replacement package would outperform
networkx in any case by a large factor.



2017-06-22 10:32 GMT-04:00 Matteo Riondato <matteo at cs.brown.edu>:
> On Jun 22, 2017, at 10:25 AM, Henning Meyerhenke
> <henning.meyerhenke at kit.edu> wrote:
> I would be against renaming addEdge for backwards compatibility reasons.
> Having a method addEdgeSafely would be possible, I guess.
> How about calling it “addEdgeAndNodes” ? “Safely” is not very descriptive,
> I like my bikeshed blue =) (https://en.wiktionary.org/wiki/bikeshedding)
> I am a bit
> concerned, though, about the theoretical consistency: how can one insert
> an edge between two nodes that are not present in the graph? But I see
> the convenience point...
> I tend to agree with you. NetworKit approach is much more granular and feels
> more correct.
> On the other hand, the proposed function would just be a utility function to
> save the user from having to
> check whether the nodes are present, add them if they are not, and then add
> the edge.
> It seems an operation that users would want to do often enough that a
> utility function would be useful.
> It may also have the advantage that it may be able to do all this by
> manipulating some internals structure not directly accessible to the user.
> My 2 cents,
> Matteo
> _______________________________________________
> NetworKit mailing list
> NetworKit at ira.uni-karlsruhe.de
> https://lists.ira.uni-karlsruhe.de/mailman/listinfo/networkit


More information about the NetworKit mailing list