Line data Source code
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 : 13 3785943 : DBGraphVertex::adjacency_iterator::adjacency_iterator() 14 3785943 : : graph_(NULL) { 15 3785943 : } 16 : 17 1163315 : DBGraphVertex::adjacency_iterator::adjacency_iterator(DBGraph *graph, 18 1163315 : Vertex vertex) 19 1163315 : : graph_(graph) { 20 1163315 : boost::tie(iter_, end_) = adjacent_vertices(vertex, *graph_->graph()); 21 1163315 : } 22 : 23 3543195 : DBGraphVertex &DBGraphVertex::adjacency_iterator::dereference() const { 24 3543195 : Vertex adj = *iter_; 25 3543195 : return *(graph_->vertex_data(adj)); 26 : } 27 : 28 1481615 : DBGraphVertex::edge_iterator::edge_iterator() 29 1481615 : : graph_(NULL), vertex_(NULL) { 30 1481615 : } 31 : 32 369257 : DBGraphVertex::edge_iterator::edge_iterator(DBGraph *graph, 33 369257 : DBGraphVertex *vertex) 34 369257 : : graph_(graph), vertex_(vertex) { 35 369257 : boost::tie(iter_, end_) = out_edges(vertex->vertex(), *graph_->graph()); 36 369257 : } 37 : 38 1109150 : DBGraphEdge &DBGraphVertex::edge_iterator::dereference() const { 39 1109150 : Edge edge = *iter_; 40 2218300 : return *(graph_->edge_data(edge)); 41 : } 42 : 43 296783 : DBGraphVertex *DBGraphVertex::edge_iterator::target() const { 44 296783 : Edge descriptor = *iter_; 45 296783 : DBGraphEdge *edge = graph_->edge_data(descriptor); 46 296783 : DBGraphVertex *v_target = edge->target(graph_); 47 296783 : if (v_target == vertex_) { 48 116896 : return edge->source(graph_); 49 : } 50 179887 : return v_target; 51 : } 52 : 53 111129 : bool DBGraphVertex::HasAdjacencies(DBGraph *graph) const { 54 111129 : DBGraphBase::adjacency_iterator iter, end; 55 111129 : boost::tie(iter, end) = adjacent_vertices(vertex_id_, *graph->graph()); 56 222258 : return (iter != end); 57 : }