Skip to content

get_weight() inconsistent changing of indexing bug #23

Description

@koleckar
  • TSPLIB 95 version: 0.7.1
  • Python version: 3.6
  • Operating System: Win
graph = tsplib95.load('data/gr17.tsp')
print(graph.get_weight(17, 1))  # IndexError: (17, 1) is out of bonuds

graph = tsplib95.load('data/gr120.tsp')
print(graph.get_weight(120, 1))  # ok


graph = tsplib95.load('data/gr17.tsp')
print(graph.get_weight(16, 0))  # ok

graph = tsplib95.load('data/gr120.tsp')
print(graph.get_weight(119, 0))  # IndexError: (118, -1) is out of bonuds

So inside get_weight() for some graphs (with exactly same edge_weight_type/format etc..) there is NONCONSISTENCY
of what the function does with indexing.
Eg.: for gr120.tsp instance there is implicit -1 for index passed into get_weight() but for gr17/24/48 there is not.

The subtracitng 1 issue I found for 'berlin52.tsp', 'pa561.tsp' and 'gr120'.

Btw there is typo in "raise IndexError(f'({i}, {j}) is out of bonuds" as well.

Also for some problems (eg: si_xxx.tsp) there is flipped 'i' and 'j' in "raise IndexError(f'({i}, {j}) is out of bonuds"

graph = tsplib95.load('data/si535.tsp')
print(graph.get_weight(535, 1)) # IndexError: (1, 535) is out of bonuds

Quite annoying bug tbh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions