Determining whether a key already exists in a labeled graph
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. -- View this message in context: http://boost.2283326.n4.nabble.com/Determining-whether-a-key-already-exists-... Sent from the Boost - Users mailing list archive at Nabble.com.
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
vertex() seems to be working for me. Thanks! -- View this message in context: http://boost.2283326.n4.nabble.com/Determining-whether-a-key-already-exists-... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
eric
-
Jeremiah Willcock