Boost.Graph how to merge two vertices/contract edge

后端 未结 3 1363
囚心锁ツ
囚心锁ツ 2021-01-02 22:46

How to merge two vertices/contract edge at Boost.Graph?

I need to move edges from vertex A to vertex B, and delete vertex A - is there any built-in function? Or mayb

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 23:14

    There is no generic function in the library because it is not possible for a generic function to know what needs to be done in the 'corner cases'. What if vertex X has an edge to both vertex A and B? Should the function simply delete X-A, or should it delete X-B and move X-A to X--B? What if the edge from X to A ( the vertex being deleted ) has properties that must be preserved or modified? Only the application code knows how to handle properties when an edge is deleted or moved

    'Delegating' these decisions, as qble suggests, makes no sense. If the decision about what to do with the properties of deleted edges is 'delegated' to the application code, then the application code is going to have to find and loop over the edges that must be deleted. So it has to repeat the same work that the generic function does. It might as well do the edge deletion itself, once it has finished with the properties of each deleted edge, and not bother calling the generic function.

提交回复
热议问题