quick start:g++ [flags ...] file ... #include <GraphVertex.h>; GraphVertex(const GraphVertex<TObject>& copy_vertex); boolean setParentGraph(Graph<TObject>* parent); DiGraph<TObject>* getParentGraph() const; static boolean initCleanUp(); static boolean finishCleanUp();
// declare the graph vertex object
//
GraphVertex<Char>* vertex[5];
Char* chr[5];
for (long i=0; i<5; i++) {
chr[i] = new Char((unichar)i);
vertex[i] = new GraphVertex<Char>(false);
vertex[i]->setItem(chr[i]);
}
description:
static const String CLASS_NAME = L"GraphVertex";
static const String DEF_PARAM = L"vertex";
static const long ERR = 41100;
static const long ERR_NULLD = 41101;
static const long ERR_NOPAR = 41102;
DiGraph<TObject>* parent_graph_d;
static MemoryManager mgr_d;
static const String& name();
boolean debug(const unichar* message) const;
~GraphVertex();
GraphVertex(boolean self_alloc = true);
GraphVertex(const GraphVertex<TObject>& copy_vertex);
boolean assign(const GraphVertex<TObject>& copy_vertex);
GraphVertex<TObject>& operator=(const GraphVertex<TObject>& arg);
boolean eq(const GraphVertex<TObject>& compare_vertex) const;
i/o methods are not defined for this class.
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 ctype = Integral::DEF_CMODE);
boolean setParentGraph(DiGraph<TObject>* parent);
DiGraph<TObject>* getParentGraph() const;
boolean insertArc(GraphVertex<TObject>* vertex, double weight = GraphArc<TObject>::DEF_WEIGHT, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON);
boolean insertArc(GraphVertex<TObject>* vertex, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON);
boolean insertArc(GraphVertex<TObject>* vertex, GraphArc<TObject>*& new_arc, double weight = GraphArc<TObject>::DEF_WEIGHT, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON);
boolean insertArc(GraphVertex<TObject>* vertex, GraphArc<TObject>*& new_arc, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON);
boolean removeArc(GraphVertex<TObject>* vertex);
boolean removeArc();
boolean removeAllArcs();
boolean isAdjacent(GraphVertex<TObject>* vertex) const;
boolean isStart() const;
boolean isTerm() const;
// create a set of test characters
//
Char* chars[128];
for (long i = 0; i < 128; i++) {
chars[i] = new Char((unichar)i);
}
// create two graphs to manipulate
//
Graph<Char> graph1(false);
Graph<Char> graph2(false);
// create an array of vertices to test
//
GraphVertex<Char>* vertices[128];
for (long i = 0; i < 128; i++) {
vertices[i] = new GraphVertex<Char>(false);
// set the item in each vertex
//
vertices[i]->setItem(chars[i]);
}
// make sure the setParentGraph and getParentGraph methods work
//
// assign one of the two graphs to each node
//
for (long i = 0; i < 64; i++) {
if (!vertices[i]->setParentGraph(&graph1)) {
Console::put(L"Error in setParentGraph");
}
}
for (long i = 64; i < 128; i++) {
if (!vertices[i]->setParentGraph(&graph2)) {
Console::put(L"Error in setParentGraph");
}
}
// make sure that the proper graph was assigned
//
for (long i = 0; i < 64; i++) {
if ((vertices[i]->getParentGraph() != &graph1) ||
(vertices[128 - i - 1]->getParentGraph() != &graph2) ||
(vertices[i]->getParentGraph() ==
vertices[128 - i - 1]->getParentGraph())) {
Console::put(L"Error in getParentGraph");
}
}