OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
db_graph_vertex.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "db/db_graph_vertex.h"
6 
7 #include "db/db_graph.h"
8 #include "db/db_graph_edge.h"
9 
10 using namespace boost;
11 
13  : graph_(NULL) {
14 }
15 
17  Vertex vertex)
18  : graph_(graph) {
19  boost::tie(iter_, end_) = adjacent_vertices(vertex, *graph_->graph());
20 }
21 
23  Vertex adj = *iter_;
24  return *(graph_->vertex_data(adj));
25 }
26 
28  : graph_(NULL), vertex_(NULL) {
29 }
30 
33  : graph_(graph), vertex_(vertex) {
34  boost::tie(iter_, end_) = out_edges(vertex->vertex(), *graph_->graph());
35 }
36 
38  Edge edge = *iter_;
39  return *(graph_->edge_data(edge));
40 }
41 
43  Edge descriptor = *iter_;
44  DBGraphEdge *edge = graph_->edge_data(descriptor);
45  DBGraphVertex *v_target = edge->target(graph_);
46  if (v_target == vertex_) {
47  return edge->source(graph_);
48  }
49  return v_target;
50 }
51 
54  boost::tie(iter, end) = adjacent_vertices(vertex_id_, *graph->graph());
55  return (iter != end);
56 }
const graph_t * graph() const
Definition: db_graph.h:91
DBGraphVertex & dereference() const
DBGraphBase::out_edge_iterator iter_
DBGraphBase::adjacency_iterator end_
DBGraphBase::adjacency_iterator iter_
adjacency_iterator end(DBGraph *graph)
DBGraphBase::out_edge_iterator end_
bool HasAdjacencies(DBGraph *graph) const
boost::graph_traits< graph_t >::adjacency_iterator adjacency_iterator
Definition: db_graph_base.h:60
DBGraphVertex * target() const
DBGraphBase::edge_descriptor Edge
DBGraphVertex * target(DBGraph *graph)
Vertex vertex() const
DBGraphBase::vertex_descriptor Vertex
DBGraphEdge & dereference() const
DBGraphVertex * source(DBGraph *graph)