Skip to content

SpanningEdgeCentrality causing memory error #967

@fabratu

Description

@fabratu

Using SpanningEdgeCentrality with non-indexed graphs occassionally causes memory errors. This can be reproduced by running the notebook-tests (i.e. Centrality.ipynb), whereas example-code doesn't include indexing of the input graph.

Example:

> python3 notebooks/test_notebooks.py 'notebooks/'
...
Start  /***/Centrality.ipynb
free(): invalid next size (fast)
/***/Centrality.ipynb test successfully completed.
...

Adding G.indexEdges() before initializing the algorithm does solve the problem:

G = nk.readGraph("../input/karate.graph", nk.Format.METIS)
G.indexEdges()
span = nk.centrality.SpanningEdgeCentrality(G, 1e-6)
span.run()

Depending on the Python version, nbconvert can also fail entirely to run the notebook. Example from the CI:

Start  notebooks/Centrality.ipynb
Traceback (most recent call last):
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/client.py", line 780, in _async_poll_for_reply
    msg = await ensure_async(self.kc.shell_channel.get_msg(timeout=new_timeout))
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/util.py", line 97, in ensure_async
    result = await obj
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/jupyter_client/channels.py", line 224, in get_msg
    ready = await self.socket.poll(timeout)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/client.py", line 1006, in async_execute_cell
    exec_reply = await self.task_poll_for_reply
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/runner/work/networkit/networkit/notebooks/test_notebooks.py", line 49, in <module>
    status += run_notebook(os.path.join(path, file))
  File "/home/runner/work/networkit/networkit/notebooks/test_notebooks.py", line 27, in run_notebook
    proc.preprocess(nb, {'metadata': {'path': dirname}})
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbconvert/preprocessors/execute.py", line 89, in preprocess
    self.preprocess_cell(cell, resources, index)
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbconvert/preprocessors/execute.py", line 110, in preprocess_cell
    cell = self.execute_cell(cell, index, store_history=True)
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/util.py", line 85, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/util.py", line 60, in just_run
    return loop.run_until_complete(coro)
  File "/opt/hostedtoolcache/Python/3.10.5/x64/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/runner/work/networkit/networkit/pyenv/lib/python3.10/site-packages/nbclient/client.py", line 1010, in async_execute_cell
    raise DeadKernelError("Kernel died")
nbclient.exceptions.DeadKernelError: Kernel died

Since this error was introduced recently, it is likely caused by changes from #957.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions