shape_doc 0.1
graph_test.cpp
# include <iostream>

# include <shape/graph.hpp>


using namespace std ;
using namespace mmx ;
using namespace shape ;




int main(int argc, char ** argv)
{

  Graph<int> gr;

  for (int i=1;i<8; i++)// 7 Vertices
    gr.push_vertex(i);

  gr.push_uedge(1,2); // Adding undirected edges
  gr.push_uedge(1,3);
  gr.push_uedge(1,4);
  gr.push_uedge(2,5);
  gr.push_uedge(2,6);
  gr.push_uedge(3,7);
  gr.push_uedge(4,6);


  gr.print(); // Print graph as adjecency list
 

  cout<<"Vertex list:\n";

  Seq<int> l;
    gr.vertex_list(l);  // Vertex list
  cout<< l;

  cout<< "\nEdge list (as couples of vertices):\n";
  l.clear();
  gr.edge_list(l);  // Edge list (as couples of vertices)
  cout<< l;

  cout<<"\nNeighbors of vertex 2:\n";
  cout<< gr.neighbors(2); // Neighbors of vertex "2"

  cout<<"\nVertex data in DFS-ordered list:\n";
  l.clear();
  gr.dfs(l);  // Vertex data in DFS-ordered list
  cout<< l ;

  cout<<"\nDFS iterator on vertices:\n";
  GraphDfsIter<int> dfs(gr); // DFS iterator on vertices
  for (dfs.first(); !dfs.isDone(); dfs.next() )
  {
    cout<< dfs.currentItem()->get_data()<< (dfs.isLast() ? "\n" :", ") ;
  }


}// main