graph.h
Go to the documentation of this file.
00001 /***
00002  Basic structure for node in minimum spanning tree
00003  ***/
00004 #ifndef _GRAPH_H
00005 #define _GRAPH_H
00006 #include <vector>
00007 #include <utility>
00008 #include <cassert>
00009 
00010 class graph
00011 {
00012 public:
00013         typedef long int                                  Vertex;
00014     typedef float                                 Weight;
00015         typedef std::pair<Vertex, Vertex> Edge;
00016 
00017         graph(Vertex vCount = 0)
00018         {
00019                 graph_.reserve(vCount + 1);
00020 
00021                 for (Vertex i = 0; i != vCount; ++i)
00022                 {
00023                         std::vector<Weight> w(vCount);
00024                         graph_.push_back(w);
00025                 }
00026         }
00027         
00028         Vertex vertexCount() const
00029         {
00030                 return graph_.size();
00031         }
00032 
00033         std::vector<Weight>& operator[](Vertex v)
00034         {
00035                 return graph_[v];
00036         }
00037 
00038         void addEdge(Vertex v1, Vertex v2, Weight w)
00039         {
00040                 assert(v1 < vertexCount());
00041                 assert(v2 < vertexCount());
00042 
00043                 graph_[v1][v2] = w;
00044         }
00045 
00046 private:
00047         std::vector<std::vector<Weight>>  graph_;
00048 };
00049 
00050 #endif


tensor_field_nav_core
Author(s): Lintao Zheng, Kai Xu
autogenerated on Thu Jun 6 2019 19:50:56