Boost logo

Boost Users :

Subject: Re: [Boost-users] Determining whether a key already exists in a labeled graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2012-10-05 18:40:42


On Fri, 5 Oct 2012, eric wrote:

> Is there a way to tell if a labeled graph already contains a key? As I'm
> constructing my graph from database data, I would like to check whether a
> node's parent already exists, and if not create it.

One thing to do is to try to insert it using insert_vertex() or
label_vertex() and check the return value. It looks like you can also
call the vertex() method with the label (or vertex_by_label() as a free
function in trunk version r80879 or above) and see if the return value is
graph_traits<GraphType>::null_vertex() (which is returned if the label was
not found).

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net