10#include "Teuchos_Graph.hpp"
14#include "Teuchos_vector.hpp"
18Graph make_graph_with_nnodes(
int nnodes) {
19 return Graph(std::size_t(nnodes));
22int get_nnodes(Graph
const& g) {
23 return Teuchos::size(g);
26void add_edge(Graph& g,
int i,
int j) {
27 at(g, i).push_back(j);
30NodeEdges
const& get_edges(Graph
const& g,
int i) {
34NodeEdges& get_edges(Graph& g,
int i) {
38int count_edges(
const Graph& g,
int i) {
39 return Teuchos::size(at(g, i));
42Graph 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);
55int at(Graph
const& g,
int i,
int j) {
56 return at(at(g, i), j);
59std::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) {
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...