atlas  0.6
graph.h
Go to the documentation of this file.
1 
5 /*
6  Copyright (C) 2004,2005 Fokko du Cloux
7  part of the Atlas of Lie Groups and Representations
8 
9  For license information see the LICENSE file
10 */
11 
12 #ifndef GRAPH_H /* guard against multiple inclusions */
13 #define GRAPH_H
14 
15 #include "graph_fwd.h"
16 #include "partition.h"
17 #include "set.h"
18 
19 /******** type definitions **************************************************/
20 
21 namespace atlas {
22 
23 /******** type declarations *************************************************/
24 
25 namespace graph {
26 
28 {
29 
30  std::vector<EdgeList> d_edges; // list of edges, outgoing from each vertex
31 
32  public:
33 
34 // constructors and destructors
36 
37  explicit OrientedGraph(size_t n):d_edges(n) {}
38 
39 // copy, construction and swap
40  void swap(OrientedGraph& other) { d_edges.swap(other.d_edges); }
41 
42 // accessors
43  void cells(partition::Partition&, OrientedGraph* p = 0) const;
44 
45  Vertex edge(Vertex x, size_t j) const { return d_edges[x][j]; } // edge #j
46 
47  const EdgeList& edgeList(const Vertex& x) const { return d_edges[x]; }
48 
49  size_t size() const { return d_edges.size(); } // number of vertices
50 
51 // manipulators
52  Vertex& edge(Vertex x, size_t j) { return d_edges[x][j]; } // allow clobbering
53 
54  EdgeList& edgeList(const Vertex& x) { return d_edges[x]; } // even globally
55 
57  { Vertex v=size(); d_edges.push_back(EdgeList()); return v; }
58 
59  void reset() { d_edges.assign(d_edges.size(),EdgeList()); } // clear edges
60 
61  void resize(size_t n) { d_edges.resize(n); } // change number of vertices
62 
63  void reverseEdges (); // make opposite oriented graph
64  void reverseNumbering (); // same graph, but reverse numbering of vertices
65 
66 
67  // auxiliary methods
68 private:
69 void addLinks
70  (const std::vector<const EdgeList*>& out, const partition::Partition& pi);
71 }; // |class OrientedGraph|
72 
73 } // |namespace graph|
74 
75 } // |namespace atlas|
76 
77 #endif
const EdgeList & edgeList(const Vertex &x) const
Definition: graph.h:47
Definition: partition.h:51
EdgeList & edgeList(const Vertex &x)
Definition: graph.h:54
Vertex & edge(Vertex x, size_t j)
Definition: graph.h:52
uA p
Definition: lists.cpp:26
set::Elt Vertex
Definition: Atlas.h:101
void reset()
Definition: graph.h:59
void reverseEdges()
Definition: graph.cpp:244
Vertex edge(Vertex x, size_t j) const
Definition: graph.h:45
size_t size() const
Definition: graph.h:49
std::vector< EdgeList > d_edges
Definition: graph.h:30
void reverseNumbering()
Definition: graph.cpp:257
#define out(c)
Definition: cweave.c:205
Definition: graph.h:27
std::vector< Edge > EdgeList
Definition: Atlas.h:104
Vertex newVertex()
Definition: graph.h:56
void addLinks(const std::vector< const EdgeList * > &out, const partition::Partition &pi)
Definition: graph.cpp:291
void cells(partition::Partition &, OrientedGraph *p=0) const
Definition: graph.cpp:128
OrientedGraph()
Definition: graph.h:35
unsigned long n
Definition: axis.cpp:77
Definition: Atlas.h:38
void swap(OrientedGraph &other)
Definition: graph.h:40
OrientedGraph(size_t n)
Definition: graph.h:37
Vertex v
Definition: graph.cpp:116
void resize(size_t n)
Definition: graph.h:61