OpenSDN source code
db_graph_vertex.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #include "db/db_graph_vertex.h"
7 
8 #include "db/db_graph.h"
9 #include "db/db_graph_edge.h"
10 
11 using namespace boost;
12 
14  : graph_(NULL) {
15 }
16 
18  Vertex vertex)
19  : graph_(graph) {
20  boost::tie(iter_, end_) = adjacent_vertices(vertex, *graph_->graph());
21 }
22 
24  Vertex adj = *iter_;
25  return *(graph_->vertex_data(adj));
26 }
27 
29  : graph_(NULL), vertex_(NULL) {
30 }
31 
34  : graph_(graph), vertex_(vertex) {
35  boost::tie(iter_, end_) = out_edges(vertex->vertex(), *graph_->graph());
36 }
37 
39  Edge edge = *iter_;
40  return *(graph_->edge_data(edge));
41 }
42 
44  Edge descriptor = *iter_;
45  DBGraphEdge *edge = graph_->edge_data(descriptor);
46  DBGraphVertex *v_target = edge->target(graph_);
47  if (v_target == vertex_) {
48  return edge->source(graph_);
49  }
50  return v_target;
51 }
52 
55  boost::tie(iter, end) = adjacent_vertices(vertex_id_, *graph->graph());
56  return (iter != end);
57 }
boost::graph_traits< graph_t >::adjacency_iterator adjacency_iterator
Definition: db_graph_base.h:61
DBGraphVertex * source(DBGraph *graph)
DBGraphVertex * target(DBGraph *graph)
DBGraphBase::adjacency_iterator iter_
DBGraphVertex & dereference() const
DBGraphBase::adjacency_iterator end_
DBGraphBase::out_edge_iterator end_
DBGraphBase::out_edge_iterator iter_
DBGraphEdge & dereference() const
DBGraphVertex * target() const
DBGraphBase::edge_descriptor Edge
Vertex vertex() const
adjacency_iterator end(DBGraph *graph)
DBGraphBase::vertex_descriptor Vertex
bool HasAdjacencies(DBGraph *graph) const
const graph_t * graph() const
Definition: db_graph.h:92