ukoethe / vigra

a generic C++ library for image analysis
http://ukoethe.github.io/vigra/
Other
411 stars 191 forks source link

Erase nodes in AdjacencyListGraph #354

Closed dstoe closed 8 years ago

dstoe commented 8 years ago

There is no function to erase nodes and arcs in the AdjacencyListGraph yet, am I right? I'd be glad if there was such a function, like there is in the lemon graph.

I tried (not very hard) to do it, but failed, as I'm not familiar with the underlying data structures.

ukoethe commented 8 years ago

We decided not to implement this capability in AdjacencyListGraph, because it might compromise execution speed when the graph is actually fixed (which is frequently the case in image analysis). However, you should be able to use the LEMON graph as a drop-in replacement, because it has the same API. (If this doesn't work, it might be considered a bug.)

Moreover, there is a (largely undocumented) class MergeGraphAdaptor in merge_graph_adaptor.hxx that may do what you need. It supports the most common graph modification in image analysis -- merging two nodes by contracting the common edge -- and automatically updates node and edge features after the modification via user-provided callbacks. Especially the latter is crucial for hierarchical clustering to work properly.

Pinging @DerThorsten, who implemented MergeGraphAdaptor .