Skip to content

Error using getDistances(asarray=True) method of distance.APSP #1366

@giobus75

Description

@giobus75

Hi,
to compute all shortest paths of a directed graph, I'm using the method getDistances(asarray=True) of distance.APSP class (networkit v. 11.1).
The graph size is about 50K nodes and 150K edges. If I run the method with asarray=False it works but if I switch on the option I get this error:


File [~/.local/lib/python3.10/site-packages/networkit/distance.pyx:1191](http://seixi011.crs4.int:8996/home/user/.local/lib/python3.10/site-packages/networkit/distance.pyx#line=1190), in networkit.distance.APSP.getDistances()

File [~/.local/lib/python3.10/site-packages/networkit/helpers.pxd:39](http://seixi011.crs4.int:8996/home/user/.local/lib/python3.10/site-packages/networkit/helpers.pxd#line=38), in networkit.helpers.maybe_asarray_2d()

File [~/.local/lib/python3.10/site-packages/networkit/helpers.pyx:170](http://seixi011.crs4.int:8996/home/user/.local/lib/python3.10/site-packages/networkit/helpers.pyx#line=169), in networkit.helpers.asarray_2d()

ValueError: negative dimensions are not allowed

This code snippet reproduces the error:

g_tmp = nk.graph.Graph(50000, weighted=False, directed=True)
dist= nk.distance.APSP(g_tmp) 
dist.run()
all_dist = dist.getDistances(asarray=True)

The error disappears if the graph size is smaller (for example: 500 nodes).

Could the error be related to the int data type at line 160 of https://github.com/networkit/networkit/blob/master/networkit/helpers.pyx meaning that with a large graph the product of num_rows * num_cols at line 170 causes an overflow?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions