COIN-OR::LEMON - Graph Library

Opened 16 years ago

Last modified 6 years ago

#250 closed enhancement

Extensions for the interface of paths — at Version 7

Reported by: Peter Kovacs Owned by: Peter Kovacs
Priority: major Milestone: LEMON 1.4 release
Component: core Version: hg main
Keywords: Cc:
Revision id:

Description (last modified by Peter Kovacs)

  1. Path structures have a function nth(int n) for getting the n th arc of the path. I suggest operator[] as an alias for this function.
  1. It would be nice to have source() and target() functions for paths. But it raise questions.
    • Is it necessary that all the arcs in a path are directed in the same direction? Or we could store oppositely directed arc in a path as well? How should we define the source/target? Would the source node be equal to gr.source(path.front()) and the target to gr.target(path.back())?
    • Should paths store source and target nodes explicitly? It would make it possible to handle paths of zero length (with a specified starting node).

Change History (9)

comment:1 Changed 16 years ago by Alpar Juttner

Milestone: LEMON 1.1 releaseLEMON 1.2 release
Owner: changed from Alpar Juttner to Balazs Dezso

comment:2 in reply to:  description ; Changed 16 years ago by Balazs Dezso

  1. It would be nice to have source() and target() functions for paths. But it raise questions.
    • Is it necessary that all the arcs in a path are directed in the same direction? Or we could store oppositely directed arc in a path as well? How should we define the source/target? Would the source node be equal to gr.source(path.front()) and the target to gr.target(path.back())?
    • Should paths store source and target nodes explicitly? It would make it possible to handle paths of zero length (with a specified starting node).

This issue was discussed when the path concepts were designed and redesigned. The final conclusion was that the path type must be very simple, because it should be possible to store a large amount of paths efficiently. The paths must be strictly directed, i.e. s(p_n) = t(p_{n-1}). There are now some global functions to get the source and target of the path. There is also global iterator for the nodes of the path, and it allows to specify the starting node of the path.

I recommend that the 2nd issue let be "wont fix".

  1. Path structures have a function nth(int n) for getting the n th arc of the path. I suggest operator[] as an alias for this function.

The nth() function can be linear in the size of the graph. The STL has a convention, that the operator[] must be sublinear. We should decide, where should we introduce this function, in every path types or in path types with sublinear running time.

comment:3 in reply to:  2 Changed 16 years ago by Peter Kovacs

Replying to deba:

This issue was discussed when the path concepts were designed and redesigned. The final conclusion was that the path type must be very simple, because it should be possible to store a large amount of paths efficiently.

I see.

The paths must be strictly directed, i.e. s(p_n) = t(p_{n-1}).

Technically you could push oppositely directed arcs into e.g. lemon::Path. Are there path tools for which it could cause problems? Should we specify this requirement at least in the Path concept?

There are now some global functions to get the source and target of the path.

They actually return gr.source(path.front()) and gr.target(path.back()). If the paths must be directed and consistent, then these functions are surely right, but only for non-empty paths. It would be better if these functions would give back INVALID for empty paths.

There is also global iterator for the nodes of the path, and it allows to specify the starting node of the path.

I recommend that the 2nd issue let be "wont fix".

I agree.

  1. Path structures have a function nth(int n) for getting the n th arc of the path. I suggest operator[] as an alias for this function.

The nth() function can be linear in the size of the graph. The STL has a convention, that the operator[] must be sublinear. We should decide, where should we introduce this function, in every path types or in path types with sublinear running time.

I think we should use this notation only for sublinear time methods.

Changed 16 years ago by Peter Kovacs

Attachment: 250-fix-e2cb320ed082.patch added

comment:4 Changed 16 years ago by Peter Kovacs

Owner: changed from Balazs Dezso to Peter Kovacs
Status: newassigned

[e2cb320ed082] fixes pathSource() and pathTarget(): they return INVALID for empty paths. I think, this changeset should be merged into both branches.

comment:5 in reply to:  4 Changed 16 years ago by Alpar Juttner

Replying to kpeter:

[e2cb320ed082] fixes pathSource() and pathTarget(): they return INVALID for empty paths. I think, this changeset should be merged into both branches.

I've rebased it ([41bdb4d6c8c3]) and merged it even into 1.0 branch.

comment:6 Changed 15 years ago by Peter Kovacs

Milestone: LEMON 1.2 releaseLEMON 1.3 release

The only question left here is to add operator[] (as an alias) for path structures that have sublinear time nth() function.

comment:7 Changed 15 years ago by Peter Kovacs

Description: modified (diff)

Changed 12 years ago by Peter Kovacs

Attachment: 250-eb2f42b62296.patch added
Note: See TracTickets for help on using tickets.