[Networkit] How to read in a large graph (and output a sparse matrix)

Maximilian Vogel maximilian.vogel at student.kit.edu
Mon Aug 1 10:24:48 CEST 2016


Hi Raphael,

you imported networkit with "import networkit", I suppose. If that's the 
case, you need to specify the format with networkit before as well: 
"networkit.Format.EdgeListSpaceOne".

And while we are at it, some more hints: If the predefined edge list 
formats do not fit your needs, you can adjust it easily, for which 
you'll need "Format.EdgeList":

  * commentPrefix='#': In case there are comments in your file, use this
    parameter to specify the first character of comment lines
  * firstNode=0: Specify the first node id (assuming the are continuous)
  * continuous=False/True: If set to true, the reader expects numbers as
    node ids and the graph object will have n = maxNodeId - firstNode
    nodes. If set to False, node ids can be anything and the graph
    object will have as many nodes as there are unique node ids.
  * directed=False/True: Specify if the edges should be interpreted as
    directed or not.

As for writing the graph, I'm not too familiar with the Matrix formats. 
Maybe networkit.graphio.writeMat is what you're looking for.

Hope this helps,
Max

On 01.08.2016 10:05, Raphael C wrote:
> This is my first attempt to use networkit.
>
> I have a simple edge list text file of size
> 1.2GB. It was 62500000 edges and about half that many vertices. Each
> line looks like
>
>       287111206 357850135
>
> I would like to read in the graph and output a sparse adjacency
> matrix.
>
> I am using python and have networkit 4.1.1 which seems to be the
> latest version available through pip.
>
> I tried to find the right function in the docs. I have attempted.
>
> G = networkit.readGraph("dgraph.edgelist", fileformat = "EdgeListSpaceOne")
> G = networkit.readGraph("dgraph.edgelist", Format.EdgeList)
>
> But both return error messages.  In fact the latter returns
>
> NameError: name 'Format' is not defined
>
> How do you read in a graph?
>
> Raphael
>
> _______________________________________________
> NetworKit mailing list
> NetworKit at ira.uni-karlsruhe.de
> https://lists.ira.uni-karlsruhe.de/mailman/listinfo/networkit

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ira.uni-karlsruhe.de/pipermail/networkit/attachments/20160801/a5b0203a/attachment-0001.html>


More information about the NetworKit mailing list