OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
policy_vertex.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
6 
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  PolicyGraphEdge *edge = graph_->edge_data(descriptor);
45  PolicyGraphVertex *v_target = edge->target(graph_);
46  if (v_target == vertex_) {
47  return edge->source(graph_);
48  }
49  return v_target;
50 }
51 
53  assert(boost::in_degree(vertex_id_, *graph->graph()) == 1);
54  PolicyGraphBase::inv_adjacency_iterator parentIt, parentEnd;
55  boost::tie(parentIt, parentEnd)
56  = boost::inv_adjacent_vertices(vertex_id_, *graph->graph());
57  return graph->vertex_data(*parentIt);
58 }
59 
61  assert(boost::in_degree(vertex_id_, *graph->graph()) == 1);
63  boost::tie(inIt, inItEnd) = in_edges(vertex_id_, *graph->graph());
64  return graph->edge_data(*inIt);
65 }
PolicyGraphEdge * edge_data(PolicyGraph::Edge edge) const
Definition: policy_graph.h:47
PolicyGraphBase::edge_descriptor Edge
Definition: policy_vertex.h:26
PolicyGraphVertex * source(PolicyGraph *graph)
Definition: policy_edge.cc:13
const graph_t * graph() const
Definition: policy_graph.h:41
PolicyGraphBase::adjacency_iterator end_
Definition: policy_vertex.h:58
graph_t::inv_adjacency_iterator inv_adjacency_iterator
PolicyGraphVertex * target(PolicyGraph *graph)
Definition: policy_edge.cc:23
PolicyGraphVertex * target() const
PolicyGraphBase::adjacency_iterator iter_
Definition: policy_vertex.h:57
PolicyGraphEdge & dereference() const
PolicyGraphBase::out_edge_iterator iter_
Definition: policy_vertex.h:85
Vertex vertex() const
PolicyGraphVertex & dereference() const
PolicyGraphBase::out_edge_iterator end_
Definition: policy_vertex.h:86
PolicyGraphVertex * parent_vertex(PolicyGraph *graph)
PolicyGraphEdge * in_edge(PolicyGraph *graph)
PolicyGraphBase::vertex_descriptor Vertex
Definition: policy_vertex.h:25
boost::graph_traits< graph_t >::in_edge_iterator in_edge_iterator
PolicyGraphVertex * vertex_data(Vertex vertex) const
Definition: policy_graph.h:43