Hi,
I have two problems
class Weights: ...
g = Graph(directed=True) weights = g.new_edge_property('object')
vertex_one = g.add_vertex() vertex_two = g.add_vertex() edge = g.add_edge(vertex_one, vertex_two) weights[edge] = Weights(1)
g.shortest_path(vertex_one, vertex_two, weights)
This raises ValueError: property map 'dist_map' is not of scalar type. Is there a function I can implement in Weights for it to return a scalar value to be used during calculation of shortest path.
Secondly, consider a directed graph where the edge weight is a function of cost at edge's origin vertex, i.e. the weight class is defined as:
class Weights: .... def get_weight(current_cost): return self.cost * current_cost
Hence during calculation of shortest_path/distance, is it possible to pass the weight at the traversed/visited edge to get the cost of the edge.
-- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 18.09.2014 11:42, ambasta wrote:
Hi,
I have two problems
class Weights: ...
g = Graph(directed=True) weights = g.new_edge_property('object')
vertex_one = g.add_vertex() vertex_two = g.add_vertex() edge = g.add_edge(vertex_one, vertex_two) weights[edge] = Weights(1)
g.shortest_path(vertex_one, vertex_two, weights)
This raises ValueError: property map 'dist_map' is not of scalar type. Is there a function I can implement in Weights for it to return a scalar value to be used during calculation of shortest path.
Take a look at the search module:
https://graph-tool.skewed.de/static/doc/search_module.html
You should use the dijkstra_search() function, and specialize the DijkstraVisitor class to do what you want.
Secondly, consider a directed graph where the edge weight is a function of cost at edge's origin vertex, i.e. the weight class is defined as:
class Weights: .... def get_weight(current_cost): return self.cost * current_cost
Hence during calculation of shortest_path/distance, is it possible to pass the weight at the traversed/visited edge to get the cost of the edge.
You can do that with the dijkstra_search() function, as I mentioned above. However, note that multiplying weights is the same as summing their logarithms... Hence you could simply use the log of the weights instead, and save you some trouble.
Best, Tiago
Hi
From what I understand of Dijkstras search, Dijkstras visitor is invoked at
traversal of a vertex. However, this is still separate from the weights which is a required argument the algorithm takes. In my case however, the weight of traversing the edge is a function of cost of traversing to the edge from the origin vertex.
I just used cost * weight as an example. In the actual algorithm, weight(edge) = interval_search(cost(edge[origin_vertex] ), interval_map) On Sep 18, 2014 7:01 PM, "Tiago Peixoto [via Main discussion list for the graph-tool project]" ml-node+s982480n4025745h58@n3.nabble.com wrote:
On 18.09.2014 11:42, ambasta wrote:
Hi,
I have two problems
class Weights: ...
g = Graph(directed=True) weights = g.new_edge_property('object')
vertex_one = g.add_vertex() vertex_two = g.add_vertex() edge = g.add_edge(vertex_one, vertex_two) weights[edge] = Weights(1)
g.shortest_path(vertex_one, vertex_two, weights)
This raises ValueError: property map 'dist_map' is not of scalar type.
Is
there a function I can implement in Weights for it to return a scalar
value
to be used during calculation of shortest path.
Take a look at the search module:
https://graph-tool.skewed.de/static/doc/search_module.html
You should use the dijkstra_search() function, and specialize the DijkstraVisitor class to do what you want.
Secondly, consider a directed graph where the edge weight is a function
of
cost at edge's origin vertex, i.e. the weight class is defined as:
class Weights: .... def get_weight(current_cost): return self.cost * current_cost
Hence during calculation of shortest_path/distance, is it possible to
pass
the weight at the traversed/visited edge to get the cost of the edge.
You can do that with the dijkstra_search() function, as I mentioned above. However, note that multiplying weights is the same as summing their logarithms... Hence you could simply use the log of the weights instead, and save you some trouble.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025745&i=0>
graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025745&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool
*signature.asc* (836 bytes) Download Attachment
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/attachment/4025745/0/signature.asc
Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
-- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 18.09.2014 21:46, ambasta wrote:
From what I understand of Dijkstras search, Dijkstras visitor is invoked at traversal of a vertex. However, this is still separate from the weights which is a required argument the algorithm takes. In my case however, the weight of traversing the edge is a function of cost of traversing to the edge from the origin vertex.
Read the documentation carefully. The visitor is invoked at several event points, one of which is "examine_edge", which is called before any edge is discovered by the algorithm. You can use this to set up the weights. This seems to be exactly what you want.
Best, Tiago
Hi Tiago,
I've tried using examine_edge. However it still doesn't cover the use case I mentioned where
Cost(edge) = function(edge, Cost_path_until_edge) = edge[interval_lookup(Cost_path_until_edge, edge.intervals)][cost_interval]
Specifically, before I compute the weight/cost of the edge, I need the cost calculated at the visitor to the edge.
Since only a single argument u(edge) is passed, I am unable to retrieve the cost at the visitor attempting to travel via this edge.
On Fri, Sep 19, 2014 at 4:09 AM, Tiago Peixoto [via Main discussion list for the graph-tool project] ml-node+s982480n4025749h82@n3.nabble.com wrote:
On 18.09.2014 21:46, ambasta wrote:
From what I understand of Dijkstras search, Dijkstras visitor is invoked at traversal of a vertex. However, this is still separate from the weights which is a required argument the algorithm takes. In my case however, the weight of traversing the edge is a function of cost of traversing to the edge from the origin vertex.
Read the documentation carefully. The visitor is invoked at several event points, one of which is "examine_edge", which is called before any edge is discovered by the algorithm. You can use this to set up the weights. This seems to be exactly what you want.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025749&i=0> _______________________________________________ graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025749&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool -- Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
On 17.11.2014 10:31, ambasta wrote:
Since only a single argument u(edge) is passed, I am unable to retrieve the cost at the visitor attempting to travel via this edge.
Just store a property map with costs, and query it using u.source().
Best, Tiago
One last bit. While using any of dijkstra/bellman_ford/astar_search function, where is the list of edges for shortest path stored?
pred_map is a Vertex Property Map, so while this can give me the list of visited vertices, I still can not find the edges which were chosen. Is there a way to retrieve a list of edges in the shortest path as well?
On Mon, Nov 17, 2014 at 7:13 PM, Tiago Peixoto [via Main discussion list for the graph-tool project] ml-node+s982480n4025851h44@n3.nabble.com wrote:
On 17.11.2014 10:31, ambasta wrote:
Since only a single argument u(edge) is passed, I am unable to retrieve the cost at the visitor attempting to travel via this edge.
Just store a property map with costs, and query it using u.source().
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025851&i=0>
graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025851&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool
*signature.asc* (836 bytes) Download Attachment
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/attachment/4025851/0/signature.asc
Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
On 17.11.2014 15:16, ambasta wrote:
One last bit. While using any of dijkstra/bellman_ford/astar_search function, where is the list of edges for shortest path stored?
pred_map is a Vertex Property Map, so while this can give me the list of visited vertices, I still can not find the edges which were chosen. Is there a way to retrieve a list of edges in the shortest path as well?
If your graph does not contain parallel edges, you can simply call the g.edge(pred_map[v], v) function. Otherwise you can simply store the edges in a list as they are visited, by properly modifying the visitor object.
Best, Tiago
If my understanding is correct, I can store the path via the edge_relaxed function, where the latest call against edge_relax indicates the edge used. Is this correct?
On Mon, Nov 17, 2014 at 7:52 PM, Tiago Peixoto [via Main discussion list for the graph-tool project] ml-node+s982480n4025854h37@n3.nabble.com wrote:
On 17.11.2014 15:16, ambasta wrote:
One last bit. While using any of dijkstra/bellman_ford/astar_search
function, where is the list of edges for shortest path stored?
pred_map is a Vertex Property Map, so while this can give me the list of
visited vertices, I still can not find the edges which were chosen. Is there a way to retrieve a list of edges in the shortest path as well?
If your graph does not contain parallel edges, you can simply call the g.edge(pred_map[v], v) function. Otherwise you can simply store the edges in a list as they are visited, by properly modifying the visitor object.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025854&i=0>
graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025854&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool
*signature.asc* (836 bytes) Download Attachment
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/attachment/4025854/0/signature.asc
Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
On 17.11.2014 15:42, ambasta wrote:
If my understanding is correct, I can store the path via the edge_relaxed function, where the latest call against edge_relax indicates the edge used. Is this correct?
Yes, this is correct.
Best, Tiago
However, since its invoked at every out of edge of a vertex being visited, is it possible to find out the cost at the vertex using *dist_map ?*
On Mon, Nov 17, 2014 at 3:00 PM, Amit Prakash Ambasta < amit.prakash.ambasta@gmail.com> wrote:
Hi Tiago,
I've tried using examine_edge. However it still doesn't cover the use case I mentioned where
Cost(edge) = function(edge, Cost_path_until_edge) = edge[interval_lookup(Cost_path_until_edge, edge.intervals)][cost_interval]
Specifically, before I compute the weight/cost of the edge, I need the cost calculated at the visitor to the edge.
Since only a single argument u(edge) is passed, I am unable to retrieve the cost at the visitor attempting to travel via this edge.
On Fri, Sep 19, 2014 at 4:09 AM, Tiago Peixoto [via Main discussion list for the graph-tool project] ml-node+s982480n4025749h82@n3.nabble.com wrote:
On 18.09.2014 21:46, ambasta wrote:
From what I understand of Dijkstras search, Dijkstras visitor is invoked at traversal of a vertex. However, this is still separate from the weights which is a required argument the algorithm takes. In my case however, the weight of traversing the edge is a function of cost of traversing to the edge from the origin vertex.
Read the documentation carefully. The visitor is invoked at several event points, one of which is "examine_edge", which is called before any edge is discovered by the algorithm. You can use this to set up the weights. This seems to be exactly what you want.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025749&i=0> _______________________________________________ graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025749&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool -- Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
-- Ameno dom, Domi ne reo Amit
An actual use case would be finding the fastest route between two cities given inconnecting flights across multiple intermediary cities. Depending on departure time, there would be different routes recommended.
Hence, on arriving at an intermediary airport X at time T, the cost to travel to the next possible intermediary airport Y would be a dependent on T.
On Fri, Sep 19, 2014 at 1:15 AM, Amit Prakash Ambasta < amit.prakash.ambasta@gmail.com> wrote:
Hi
From what I understand of Dijkstras search, Dijkstras visitor is invoked at traversal of a vertex. However, this is still separate from the weights which is a required argument the algorithm takes. In my case however, the weight of traversing the edge is a function of cost of traversing to the edge from the origin vertex.
I just used cost * weight as an example. In the actual algorithm, weight(edge) = interval_search(cost(edge[origin_vertex] ), interval_map) On Sep 18, 2014 7:01 PM, "Tiago Peixoto [via Main discussion list for the graph-tool project]" ml-node+s982480n4025745h58@n3.nabble.com wrote:
On 18.09.2014 11:42, ambasta wrote:
Hi,
I have two problems
class Weights: ...
g = Graph(directed=True) weights = g.new_edge_property('object')
vertex_one = g.add_vertex() vertex_two = g.add_vertex() edge = g.add_edge(vertex_one, vertex_two) weights[edge] = Weights(1)
g.shortest_path(vertex_one, vertex_two, weights)
This raises ValueError: property map 'dist_map' is not of scalar type.
Is
there a function I can implement in Weights for it to return a scalar
value
to be used during calculation of shortest path.
Take a look at the search module:
https://graph-tool.skewed.de/static/doc/search_module.html
You should use the dijkstra_search() function, and specialize the DijkstraVisitor class to do what you want.
Secondly, consider a directed graph where the edge weight is a function
of
cost at edge's origin vertex, i.e. the weight class is defined as:
class Weights: .... def get_weight(current_cost): return self.cost * current_cost
Hence during calculation of shortest_path/distance, is it possible to
pass
the weight at the traversed/visited edge to get the cost of the edge.
You can do that with the dijkstra_search() function, as I mentioned above. However, note that multiplying weights is the same as summing their logarithms... Hence you could simply use the log of the weights instead, and save you some trouble.
Best, Tiago
-- Tiago de Paula Peixoto <[hidden email] http://user/SendEmail.jtp?type=node&node=4025745&i=0>
graph-tool mailing list [hidden email] http://user/SendEmail.jtp?type=node&node=4025745&i=1 http://lists.skewed.de/mailman/listinfo/graph-tool
*signature.asc* (836 bytes) Download Attachment
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/attachment/4025745/0/signature.asc
Tiago de Paula Peixoto tiago@skewed.de
If you reply to this email, your message will be added to the discussion below:
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... To unsubscribe from Using a EdgePropertyMap('object') as weights, click here http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4025744&code=YW1pdC5wcmFrYXNoLmFtYmFzdGFAZ21haWwuY29tfDQwMjU3NDR8MTk5MTkwNzYwMQ== . NAML http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml