10 #include "Teuchos_Graph.hpp"
14 #include "Teuchos_vector.hpp"
18 Graph make_graph_with_nnodes(
int nnodes) {
19 return Graph(std::size_t(nnodes));
22 int get_nnodes(Graph
const& g) {
23 return Teuchos::size(g);
26 void add_edge(Graph& g,
int i,
int j) {
27 at(g, i).push_back(j);
30 NodeEdges
const& get_edges(Graph
const& g,
int i) {
34 NodeEdges& get_edges(Graph& g,
int i) {
38 int count_edges(
const Graph& g,
int i) {
39 return Teuchos::size(at(g, i));
42 Graph make_transpose(Graph
const& g) {
43 int nnodes = get_nnodes(g);
44 Graph transpose = make_graph_with_nnodes(nnodes);
45 for (
int i = 0; i < nnodes; ++i) {
46 const NodeEdges& edges = get_edges(g, i);
47 for (NodeEdges::const_iterator it = edges.begin(); it != edges.end(); ++it) {
49 add_edge(transpose, j, i);
55 int at(Graph
const& g,
int i,
int j) {
56 return at(at(g, i), j);
59 std::ostream& operator<<(std::ostream& os, Graph
const& g) {
60 for (
int i = 0; i < get_nnodes(g); ++i) {
62 const NodeEdges& edges = get_edges(g, i);
63 for (NodeEdges::const_iterator it = edges.begin(); it != edges.end(); ++it) {