[vtkusers] Creating the dual of a graph - planar face traversal - vtkBoostGraphAdapter

Jeff Baumes jeff.baumes at kitware.com
Wed Oct 8 15:13:26 EDT 2014


In your code, you are retrieving a vtkGraphIndexMap with:

property_map<vtkUndirectedGraph*, edge_index_t>::type e_index =
get(edge_index, in);

vtkGraphIndexMap is intended to be read-only and is already populated with
indices 0 through N-1, which are accessed with get(). It's actually an
identity map by index since indices are always in order, as you can see
here:

https://github.com/Kitware/VTK/blob/master/Infovis/BoostGraphAlgorithms/vtkBoostGraphAdapter.h#L1032-L1049

So I would suggest leaving out your initialization loop on lines 43-45.

Now, the remaining errors seem to require an operator[] on the
EdgeIndexMap, which is not currently implemented in vtkBoostGraphAdapter.h.
The needed code would be to replace the definition of vtkGraphPropertyMap
with something like this (not tested):

struct vtkGraphIndexMap; // forward declaration

template <>
struct property_traits<vtkGraphIndexMap>
{
  typedef vtkIdType value_type;
  typedef vtkIdType reference;
  typedef vtkIdType key_type;
  typedef readable_property_map_tag category;
};

struct vtkGraphIndexMap
{
  property_traits<vtkGraphIndexMap>::reference operator[](const
property_traits<vtkGraphIndexMap>::key_type& b)
    {
    return key;
    }
};


HTH,
Jeff

On Wed, Oct 8, 2014 at 2:12 PM, Szilárd Szalóki <szilardszaloki at gmail.com>
wrote:

> Hi All,
>
> I'm trying to write an algorithm which creates the dual of a graph. To
> check whether the graph is planar or not I use the *Boyer-Myrvold
> planarity test* (Boost implementation) through the vtkBoostGraphAdapter.
> That works fine (only on vtkUndirectedGraph-s but that's OK for now).
> (http://www.boost.org/doc/libs/1_56_0/libs/graph/doc/boyer_myrvold.html)
>
> To create the dual I need to traverse the faces of the planar graph for
> which I also have a Boost tool called the planar_face_traversal_visitor.
> (
> http://www.boost.org/doc/libs/1_56_0/libs/graph/doc/planar_face_traversal.html
> )
> There's a guy, Aaron Windsor who implemented the appropriate visitor class
> that is able to create the dual of a graph in Boost.
> (https://github.com/aaw/boost_planar_graph_dual)
> That also works fine using only Boost but I'd like to adapt this feature
> as well using vtkBoostGraphAdapter.
>
> Here's my code: http://pastebin.com/g0Mtw6Ph
>
> These are my errors:
>
>    - *vtkDualGraph.cpp*:44:9: No matching function for call to 'put'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>    vtkEdgeType, std::__1::less<long long>,
>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::map<long long,
>    vtkEdgeType, std::__1::less<long long>,
>    std::__1::allocator<std::__1::pair<const long long, vtkEdgeType> > > *>,
>    boost::vtkGraphIndexMap, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > >, std::__1::map<long long, vtkEdgeType,
>    std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long
>    long, vtkEdgeType> > > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:302:19:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>    - /usr/local/boost_1_56_0/boost/property_map/*property_map.hpp*:309:5:
>    No viable overloaded operator[] for type 'const
>    boost::iterator_property_map<std::__1::__wrap_iter<std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > *>,
>    boost::vtkGraphIndexMap, std::__1::set<long long, std::__1::less<long
>    long>, std::__1::allocator<long long> >, std::__1::set<long long,
>    std::__1::less<long long>, std::__1::allocator<long long> > &>'
>    - /usr/local/boost_1_56_0/boost/*planar_dual.hpp*:38:38: No viable
>    overloaded operator[] for type 'edge_to_face_map_t' (aka
>    'iterator_property_map<typename vertex_vector_t::iterator,
>    boost::vtkGraphIndexMap>')
>
> It seems I cannot provide an appropriate EdgeIndexMap parameter to the
> put function in the 44th line. The vtkBoostGraphAdapter says that we can
> use VTK arrays as property maps, I tried that one as well, with no success.
> I've been dealing with this, reading the source code really deep and trying
> a couple of things in the past few days but I can't really figure out what
> the problem is. Is the vtkBoostGraphAdapter properly prepared for this
> kind of usage?
>
> Any kind of help appreciated!
>
> Thanks in advance!
>
> Szilard
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20141008/98e8bc6c/attachment.html>


More information about the vtkusers mailing list