lgraph.h

Go to the documentation of this file.
00001 #ifndef LGRAPH_H
00002 #define LGRAPH_H
00003 
00004 // linked list graph, use string as identifier,
00005 // slower, but more direct
00006 
00007 #include <list>
00008 #include <map>
00009 #include <iostream>
00010 #include <vector>
00011 #include <string>
00012 
00013 using namespace std;
00014 
00018 struct vertexinfo {
00019         vertexinfo() : id(), color('w'), parent(-1), discover(-1), finish(-1), numchildren(0) {}
00020 
00021         vertexinfo(const string &label) : id(label), color('w'), parent(-1), discover(-1), finish(-1), numchildren(0) {}
00022         string id;  // identifier for this vertex
00023         char color; // w for white, g for gray, b for black
00024         int discover;
00025         int finish;
00026         int parent;
00027         int low;     // discover time
00028         int numchildren;
00029 };
00030 
00031 /*
00032 struct edge {
00033         edge() : src(-1), dst(-1), type('x') {}
00034         edge(int s, int d, char t) : src(s), dst(d), type(t) {}
00035         int src;
00036         int dst;
00037         char type; // t for tree edge, b for back edges
00038 };
00039 */
00040 
00041 class lgraph {
00042         public:
00043                 lgraph() : adjl(), vertices(), time(0) {}
00044                 // construct the graph from a file
00045                 lgraph(istream &ins);
00046                 // read from table
00047                 //void fromDB(const string &tab);
00048                 void fromSQL(const string &query);
00049                 void dfs();
00050                 void dfsvisit(const int u);
00051                 void show(); // debug to display content of graph
00052                 vector<string> articulation();
00053         private:
00054                 int time;   // sequence of vertex discovery and finish
00055                 vector<vertexinfo> vertices;
00056                 vector<list<int> > adjl;  // adjency list
00057 };
00058 #endif

Generated on Wed Aug 10 11:56:50 2011 for Softwares from Orpara by  doxygen 1.5.6