1 #include "Teuchos_Graph.hpp"
5 #include "Teuchos_vector.hpp"
9 Graph make_graph_with_nnodes(
int nnodes) {
10 return Graph(std::size_t(nnodes));
13 int get_nnodes(Graph
const& g) {
17 void add_edge(Graph& g,
int i,
int j) {
18 at(g, i).push_back(j);
21 NodeEdges
const& get_edges(Graph
const& g,
int i) {
25 NodeEdges& get_edges(Graph& g,
int i) {
29 int count_edges(
const Graph& g,
int i) {
30 return size(at(g, i));
33 Graph make_transpose(Graph
const& g) {
34 int nnodes = get_nnodes(g);
35 Graph transpose = make_graph_with_nnodes(nnodes);
36 for (
int i = 0; i < nnodes; ++i) {
37 const NodeEdges& edges = get_edges(g, i);
38 for (NodeEdges::const_iterator it = edges.begin(); it != edges.end(); ++it) {
40 add_edge(transpose, j, i);
46 int at(Graph
const& g,
int i,
int j) {
47 return at(at(g, i), j);
50 std::ostream& operator<<(std::ostream& os, Graph
const& g) {
51 for (
int i = 0; i < get_nnodes(g); ++i) {
53 const NodeEdges& edges = get_edges(g, i);
54 for (NodeEdges::const_iterator it = edges.begin(); it != edges.end(); ++it) {