13 #ifndef ECOLAB_IGRAPH_H 14 #define ECOLAB_IGRAPH_H 16 #include "igraph/igraph.h" 26 const char* what()
const throw()
27 {
return igraph_strerror(err);}
32 static int errorhandler;
33 void addEdges(
const Graph& g);
36 IGraph(
unsigned nodes=0,
bool directed=
false)
37 {igraph_empty(
this, nodes, directed);}
45 try {igraph_destroy(
this);}
46 catch (std::exception& ex) {
47 std::cerr <<
"unexpected exception encountered: "<<
54 {igraph_copy(
this,&x);
return *
this;}
68 g(&graph) {igraph_eit_create(g,es,&it);}
73 IGRAPH_EIT_END(it) && IGRAPH_EIT_END(x.it)) ||
74 (!IGRAPH_EIT_END(it) && !IGRAPH_EIT_END(x.it) && operator*()==*x);
76 bool operator!=(
const const_iterator& x)
const {
return !operator==(x);}
77 Edge operator*()
const {
78 igraph_integer_t from, to;
79 igraph_edge(g, IGRAPH_EIT_GET(it), &from, &to);
83 const Edge* operator->()
const {
96 igraph_es_all(&es,IGRAPH_EDGEORDER_ID);
108 unsigned nodes()
const {
return igraph_vcount(
this);}
109 unsigned links()
const {
return igraph_ecount(
this);}
110 void push_back(
const Edge& e)
112 unsigned n=nodes(), maxN=std::max(e.source(), e.target())+1;
113 if (n<maxN) igraph_add_vertices(
this,maxN-n,0);
114 igraph_add_edge(
this, e.source(), e.target());
117 bool contains(
const Edge& e)
const {
118 igraph_integer_t eid;
119 #ifdef IGRAPH_VERSION 120 return igraph_get_eid(
this,&eid,e.source(),e.target(),
true,
true)==0;
123 igraph_get_eid(
this,&eid,e.source(),e.target(),
true);
126 catch (std::exception) {
return false;}
130 bool directed()
const {
return igraph_is_directed(
this);}
132 void clear(
unsigned nodes=0) {
134 igraph_destroy(
this);
135 igraph_empty(
this,nodes,dir);
virtual unsigned nodes() const =0
number of nodes
virtual bool directed() const =0
true if a bidirectional graph (all edges go both ways)
IGraph(unsigned nodes=0, bool directed=false)
construct an iGraph with nodes, directed or not
Definition: igraph.h:36
_OPENMP
Definition: accessor.h:16