[Networkit] Efficient ways to load edges from NumPy arrays

Henning Meyerhenke henning.meyerhenke at kit.edu
Wed Jul 26 10:58:36 CEST 2017


Hi Ivan,

I myself have nearly no experience with numpy. But using GraphEvent
looks a bit like a detour. Have you considered addEdge (C++ interface
below)?

void addEdge(node u, node v, edgeweight ew = defaultEdgeWeight);

I don't know if this is faster, but it may be worth a try.

Best,
Henning


Am 25.07.17 um 22:40 schrieb Ivan Raikov:
> Hello,
> 
> I would like to load a directed graph into NetworKit from an
> HDF5-based sparse graph representation. I am able to load the source
> and destination indices in numpy arrays, and then used a generator and
> GraphUpdater to iterate over the edges and instantiate the graph:
> 
> h5g = load_h5graph(input_file)
> 
> def graph_stream(h5g):
>     for (sources, destinations) in h5g.items():
>             ## sources and destinations are uint32 numpy arrays
>             for (src,dst) in zip(sources,destinations):
>                 yield (GraphEvent(GraphEvent.EDGE_ADDITION, src, dst, 1.0))
> 
> g = Graph(n_nodes, False, True)
> gu = GraphUpdater(g)
> gu.update(graph_stream(h5g))
> 
> This worked for a graph with about 1e6 edges, although I have not yet
> tested with larger graphs. I was wondering if anyone could recommend
> better ways to do this. Thanks and best regards,
> 
> -Ivan
> 
> _______________________________________________
> NetworKit mailing list
> NetworKit at ira.uni-karlsruhe.de
> https://lists.ira.uni-karlsruhe.de/mailman/listinfo/networkit
> 

-- 

==========================================================
Karlsruhe Institute of Technology (KIT)
Institute of Theoretical Informatics (ITI)

Prof. Dr. Henning Meyerhenke
Theoret. Informatics / Parallel Computing

Phone: +49-721-608-41876
Web: http://parco.iti.kit.edu/henningm/

KIT - The Research University in the Helmholtz Association
==========================================================

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5399 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.ira.uni-karlsruhe.de/pipermail/networkit/attachments/20170726/e7916675/attachment.p7s>


More information about the NetworKit mailing list