[Networkit] Error on writing

Christian Staudt christian.staudt at kit.edu
Mon Jul 6 16:09:14 CEST 2015


Could you please implement a solution that checks this for all readers and writers? Having this on the Python layer is good enough for me.

On 06 Jul 2015, at 15:35, Maximilian Vogel <maximilian.vogel at student.kit.edu> wrote:

> "the best way to check the path" is/has been discussed on SO. I think, these two discussion give some insight:
> http://stackoverflow.com/questions/82831/check-whether-a-file-exists-using-python
> http://stackoverflow.com/questions/2259382/pythonic-way-to-check-if-a-file-exists
> 
> There are two options, one should at least do:
> Either, use os.path.exists/isfile(path) in an if-clause OR
> surround the writer.write(...)-call with a try-except block catching the matching error.
> 
> 
> On 06.07.2015 15:24, Christian Staudt wrote:
>> Apparently a typo in the file path leads to an error like this, which should not happen. What is the best way to check the         path and throw a meaningful error?
>> 
>> 
>> On 06 Jul 2015, at 15:07, Christian Staudt <christian.staudt at kit.edu> wrote:
>> 
>>> Hi NetworKit developers,
>>> now I have a support question too: I want to write a weighted graph to an edge list of the format
>>> 	u	v 	w
>>> where u and v are the end nodes and w is an edge weight. If I try to do that graphio.EdgeListWriter throws an error with empty text:
>>> 
>>> 
>>> 
>>> 
>>> In [2]: G = readGraph("/Users/cls/Downloads/opsahl-usairport/out.opsahl-usairport", Format.KONECT)
>>> 
>>> In [3]: U = G.toUndirected()
>>> 
>>> In [4]: writeGraph(U, "airtraffic.graph", Format.EdgeListTabZero)
>>> ---------------------------------------------------------------------------
>>> RuntimeError                              Traceback (most recent call last)
>>> <ipython-input-4-3f775e968492> in <module>()
>>> ----> 1 writeGraph(U, "/Users/cls/workspace/AlgoIProgrammieraufgabe/data/airtraffic.graph", Format.EdgeListTabZero)
>>> 
>>> /Users/cls/workspace/NetworKit/networkit/graphio.py in writeGraph(G, path, fileformat, **kwargs)
>>>     209 	"""
>>>     210         writer = getWriter(fileformat, **kwargs)
>>> --> 211         writer.write(G, path)
>>>     212         logging.info("wrote graph {0} to file {1}".format(G, path))
>>>     213
>>> 
>>> _NetworKit.pyx in _NetworKit.EdgeListWriter.write (networkit/_NetworKit.cpp:21233)()
>>> 
>>> RuntimeError:
>>> 
>>> I’ve also modified the writer so that it writes the desired format, but I keep getting the error.
>>> 
>>> Best,
>>> Chris
>>> 
>>> <signature.asc><ATT00001.c>
>> 
> 
> <ATT00001.c>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150706/a5cfa1ef/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20150706/a5cfa1ef/attachment.sig>


More information about the NetworKit mailing list