Home | History | Annotate | Download | only in ceres

Lines Matching refs:Vertex

45 // A weighted undirected graph templated over the vertex ids. Vertex
47 template <typename Vertex>
52 // Add a weighted vertex. If the vertex already exists in the graph,
54 void AddVertex(const Vertex& vertex, double weight) {
55 if (vertices_.find(vertex) == vertices_.end()) {
56 vertices_.insert(vertex);
57 edges_[vertex] = HashSet<Vertex>();
59 vertex_weights_[vertex] = weight;
62 // Uses weight = 1.0. If vertex already exists, its weight is set to
64 void AddVertex(const Vertex& vertex) {
65 AddVertex(vertex, 1.0);
68 bool RemoveVertex(const Vertex& vertex) {
69 if (vertices_.find(vertex) == vertices_.end()) {
73 vertices_.erase(vertex);
74 vertex_weights_.erase(vertex);
75 const HashSet<Vertex>& sinks = edges_[vertex];
76 for (typename HashSet<Vertex>::const_iterator it = sinks.begin();
78 if (vertex < *it) {
79 edge_weights_.erase(make_pair(vertex, *it));
81 edge_weights_.erase(make_pair(*it, vertex));
83 edges_[*it].erase(vertex);
86 edges_.erase(vertex);
96 void AddEdge(const Vertex& vertex1, const Vertex& vertex2, double weight) {
112 void AddEdge(const Vertex& vertex1, const Vertex& vertex2) {
116 // Calling VertexWeight on a vertex not in the graph will result in
118 double VertexWeight(const Vertex& vertex) const {
119 return FindOrDie(vertex_weights_, vertex);
126 double EdgeWeight(const Vertex& vertex1, const Vertex& vertex2) const {
134 // Calling Neighbors on a vertex not in the graph will result in
136 const HashSet<Vertex>& Neighbors(const Vertex& vertex) const {
137 return FindOrDie(edges_, vertex);
140 const HashSet<Vertex>& vertices() const {
149 HashSet<Vertex> vertices_;
150 HashMap<Vertex, double> vertex_weights_;
151 HashMap<Vertex, HashSet<Vertex> > edges_;
152 HashMap<pair<Vertex, Vertex>, double> edge_weights_;