Commit a3eae6a3 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

tsp_tour(): raise exception for directed graphs

This closes issue #293
parent 91843211
Pipeline #170 passed with stage
......@@ -2302,7 +2302,7 @@ def tsp_tour(g, src, weight=None):
Parameters
----------
g : :class:`~graph_tool.Graph`
Graph to be used.
Graph to be used. The graph must be undirected.
src : :class:`~graph_tool.Vertex`
The source (and target) of the tour.
weight : :class:`~graph_tool.PropertyMap` (optional, default: None)
......@@ -2335,6 +2335,8 @@ def tsp_tour(g, src, weight=None):
"""
if g.is_directed():
raise ValueError("The graph must be undirected.")
tour = libgraph_tool_topology.\
get_tsp(g._Graph__graph, int(src), _prop("e", g, weight))
return tour.a.copy()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment