quick start:g++ [flags ...] file ... #include <BiGraph.h> BiGraph(const BiGraph<TObject>& copy_graph); boolean isWeighted() const; boolean setWeighted(boolean is_weighted = true);
description:// declare the graph object // BiGraph<Char> graph; // create some data // Char* char_a = new Char('a'); Char* char_b = new Char('b'); // create and add the vertices to the graph // BiGraphVertex<Char>* vertex_a = graph.insertVertex(char_a); BiGraphVertex<Char>* vertex_b = graph.insertVertex(char_b); // draw arcs between the vertices // graph.insertArc(graph.getStart(), vertex_a, false, 0.75); graph.insertArc(vertex_a, vertex_b, false, 0.75); graph.insertArc(vertex_b, graph.getTerm(), false, 0.75); // write it in an Sof file // String tmp_filename(L"graph"); Sof tmp_file; tmp_file.open(tmp_filename, File::WRITE_ONLY, File::TEXT); graph.write(tmp_file, 1); tmp_file.close();
static const String CLASS_NAME = L"BiGraph";
static const String DEF_PARAM = L"";
static const String PARAM_VERTICES = L"vertices";
static const String PARAM_ARCS = L"arcs";
static const String PARAM_WEIGHTED = L"weighted";
static const String START_NAME = L"_START_";
static const String TERM_NAME = L"_TERM_";
static const TObject START_OBJ;
static const TObject TERM_OBJ;
static const long START_INDEX = -1;
static const long TERM_INDEX = -2;
static const boolean DEF_IS_WEIGHTED = true;error codes:
static const long ERR = 41200;
static const long ERR_EPSCYC = 41201;
static const long ERR_MULPAR = 41202;
typedef Triple< Pair, Float, Boolean> TopoTriple;
typedef HashTable< String, BiGraphVertex> ReadHash;
BiGraphVertex<TObject>* start_vertex_d;
BiGraphVertex<TObject>* term_vertex_d;
ColorHash<TObject>* chash_d;
Boolean is_weighted_d;
ALLOCATION alloc_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean setDebug(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~BiGraph();
BiGraph(ALLOCATION alloc = DEF_ALLOCATION);
BiGraph(const BiGraph<TObject>& copy_graph);
boolean assign(const BiGraph<TObject>& copy_graph);
boolean assign(const DiGraph<TObject>& copy_graph);
boolean assign(DoubleLinkedList<TObject>& data, DoubleLinkedList<TopoTriple>& arcs);
BiGraph<TObject>& operator=(const BiGraph<TObject>& arg);
boolean eq(const BiGraph<TObject>& compare_vertex) const;
long sofSize() const;
boolean read(Sof& sof, long tag);
boolean read(Sof& sof, long tag, const String& name);
boolean write(Sof& sof, long tag) const;
boolean write(Sof& sof, long tag, const String& name) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
boolean readDataText(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean readDataBinary(Sof& sof);
boolean writeDataText(Sof& sof, const String& pname, DoubleLinkedList& dlist, DoubleLinkedList & alist) const;
boolean writeDataBinary(Sof& sof, const String& pname, DoubleLinkedList& dlist, DoubleLinkedList & alist) const;
void* operator new(size_t size);
void* operator new[](size_t size);
void operator delete(void* ptr);
void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
boolean insertArc(long start_index, long end_index, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON, float weight = BiGraphArc::DEF_WEIGHT)
boolean insertArc(BiGraphArc<TObject>* start_vertex, BiGraphArc<TObject>* end_vertex, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON, float weight = BiGraphArc::DEF_WEIGHT)
boolean removeArc(long start_index, long end_index);
boolean removeArc(BiGraphVertex* start_vertex, BiGraphVertex * end_vertex);
BiGraphVertex<TObject>* insertVertex(TObject* arg);
boolean removeVertex();
boolean removeVertex(TObject*& arg);
boolean find(const TObject* obj);
boolean find(BiGraphVertex<TObject>* vertex);
boolean contains(const TObject* obj);
boolean contains(BiGraphVertex<TObject>* vertex);
BiGraphVertex<TObject>* getStart() const;
BiGraphVertex<TObject>* getTerm() const;
boolean get(DoubleLinkedList& data, DoubleLinkedList , Float, Boolean> >& arcs);
boolean isWeighted() const;
boolean setWeighted(boolean is_weighted = true);
boolean topologicalSort(SingleLinkedList<TObject>& sorted_data, boolean partial = false);
Integral::COLOR Graph::getColor(BiGraphVertex* vertex) const;
boolean setColor(Integral::COLOR col);
boolean releaseColorHash();
boolean invertColor();
boolean makeColorHash(Integral::COLOR col = Integral::DEF_COLOR);
boolean setColor(Integral::COLOR col);
boolean isColor(Integral::COLOR col);
boolean replaceColor(Integral::COLOR old_col, Integral::COLOR new_col);
boolean dfsVisit(BiGraphVertex<TObject>& vertex);
ALLOCATION getAllocationMode() const
boolean setAllocationMode(ALLOCATION alloc)
using DoubleLinkedList< BiGraphVertex>::length;
using DoubleLinkedList< BiGraphVertex>::gotoFirst;
using DoubleLinkedList< BiGraphVertex>::gotoNext;
using DoubleLinkedList< BiGraphVertex>::gotoPrev;
using DoubleLinkedList< BiGraphVertex>::getCurr;
using DoubleLinkedList< BiGraphVertex>::getFirst;
using DoubleLinkedList< BiGraphVertex>::getLast;
using DoubleLinkedList< BiGraphVertex>::gotoMark;
using DoubleLinkedList< BiGraphVertex>::setMark;
using DoubleLinkedList< BiGraphVertex>::gotoPosition;
using DoubleLinkedList< BiGraphVertex>::getPosition;
boolean readVertexDataText(Sof& sof_a, SofParser& parser, HashTable>& hash_table) const;
boolean readArcDataText(Sof& sof_a, SofParser& parser, HashTable>& hash_table) const;
boolean writeVertexDataText(Sof& sof, SingleLinkedList& data) const;
boolean writeArcDataText(Sof& sof, SingleLinkedList, Float, Boolean> >& arcs) const;
boolean dfsVisitTS(SingleLinkedList<TObject>& output, BiGraphVertex<TObject>& vertex);examples:
// declare the graph object // BiGraph<Char> graph(DstrBase::USER); // perform the required assignments // Char* chr_a = new Char(L'a'); BiGraphVertex<Char>* vertex_a = graph.insertVertex(chr_a); graph.insertArc(graph.getStart(), vertex_a, true); Char* chr_b = new Char(L'b'); BiGraphVertex<Char>* vertex_b = graph.insertVertex(chr_b); graph.insertArc(graph.getStart(), vertex_b, true); Char* chr_c = new Char(L'c'); BiGraphVertex<Char>* vertex_c = graph.insertVertex(chr_c); graph.insertArc(graph.getStart(), vertex_c, true); Char* chr_d = new Char(L'd'); BiGraphVertex<Char>* vertex_d = graph.insertVertex(chr_d); graph.insertArc(graph.getStart(), vertex_d, true); // connect two vertices using the insertArc method // graph.insertArc(vertex_a,vertex_d, false, (float)0.7); graph.insertArc(vertex_b, vertex_d, false, (float)0.9); graph.insertArc(vertex_c, vertex_d, false, (float)3.7); graph.insertArc(vertex_d, graph.getTerm(), true); // clean up allocated memory // graph.clear(Integral::FREE);