Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: experimental/webgtt/graph.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/webgtt/build.scons ('k') | experimental/webgtt/graph.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be found
3 // in the LICENSE file.
4
5 #ifndef EXPERIMENTAL_WEBGTT_GRAPH_H_
6 #define EXPERIMENTAL_WEBGTT_GRAPH_H_
7
8 /// @fileoverview This file provides an implementation of a Graph data
9 /// structure, which constructs a graph given the number of vertices and the
10 /// adjacency matrix. It implements the graph algorithms required by webgtt.cc,
11 /// which handles browser communication. Basically, this data structure can be
12 /// thought of as a wrapper for Boost's Graph interface (we internally use
13 /// Boost's graph representation and algorithms). At the moment, only
14 /// undirected, unweighted graphs are supported.
15 ///
16 /// @author ragad@google.com (Raga Gopalakrishnan)
17
18 #include <boost/graph/graph_traits.hpp>
19
20 #include <vector>
21
22 namespace graph {
23
24 /// This function extends the Boost library of graph algorithms. It finds a
25 /// coloring of the graph, given the adjacency matrix.
26 ///
27 /// Definition: A valid coloring of a graph consists of a color for each
28 /// vertex of the graph, such that no two vertices that are connected by an
29 /// edge share the same color. A minimum coloring is a valid coloring that
30 /// uses as few colors as possible.
31 /// Algorithm Choice: Finding a minimum coloring is an NP-complete problem,
32 /// and therefore, in this algorithm, we focus on finding a valid coloring.
33 /// Of course, assigning each vertex a different color is a trivial valid
34 /// coloring! But we want to do something better, that would use far fewer
35 /// colors in most cases. We use a greedy coloring technique, and the Boost
36 /// implementation of this technique, outlined at
37 /// http://www.boost.org/doc/libs/1_47_0/libs/graph/doc/constructing_algorithms. html
38 ///
39 /// @param[in] graph The graph object.
40 /// @param[in] order A property map object that maps vertex indices to their
41 /// corresponding vertex descriptors.
42 /// @param[in] color A property map object that maps vertex descriptors to
43 /// their corresponding vertex colors.
44 /// @return The number of colors used to color the graph.
45 template <class VertexListGraph, class Order, class Color>
46 typename boost::graph_traits<VertexListGraph>::vertices_size_type
47 SequentialVertexColoring(const VertexListGraph& graph,
48 Order order,
49 const Color& color);
50
51 /// The Graph class. This class is a wrapper for Boost's graph representation
52 /// and algorithms.
53 class Graph {
54 public:
55 /// The constructor creates a Graph object given the number of vertices and
56 /// the adjacency matrix.
57 ///
58 /// @param[in] number_of_vertices The number of vertices in the graph.
59 /// @param[in] adjacency_matrix The adjacency matrix of the graph.
60 /// @constructor
61 Graph(int number_of_vertices,
62 std::vector< std::vector<int> > adjacency_matrix);
63
64 /// This function returns a greedy vertex coloring of the graph. Internally,
65 /// it uses SequentialVertexColoring, an algorithm provided here as an
66 /// extension of Boost's graph algorithms.
67 ///
68 /// @return A vector containing a valid coloring of the graph.
69 std::vector<int> GetColoring() const;
70
71 private:
72 int number_of_vertices_;
73 std::vector< std::vector<int> > adjacency_matrix_;
74 /// This disallows usage of the assignment constructor.
75 void operator=(const Graph&);
76 };
77
78 } // namespace graph
79
80 #endif // EXPERIMENTAL_WEBGTT_GRAPH_H_
OLDNEW
« no previous file with comments | « experimental/webgtt/build.scons ('k') | experimental/webgtt/graph.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698