quick start:g++ [flags ...] file ... #include <UGraph.h> UGraph(const UGraph<TObject>& copy_graph); boolean insertArc(GraphArc<TObject>* start_vertex, GraphArc<TObject>* end_vertex, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON, float weight = GraphArc::DEF_WEIGHT); boolean insertArc(GraphArc<TObject>* start_vertex, GraphArc<TObject>* end_vertex, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON, float weight = GraphArc ::DEF_WEIGHT); boolean removeArc(long start_index, long end_index); boolean removeArc(GraphVertex * start_vertex, GraphVertex * end_vertex);
// declare the graph object
//
UGraph<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
//
GraphVertex<Char>* vertex_a = graph.insertVertex(char_a);
GraphVertex<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();
description:
static const String CLASS_NAME = L"UGraph";
inherited from the base DiGraph class.
inherited from the base DiGraph class.
inherited from the base DiGraph class.
inherited from the base DiGraph class.required public methods:
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
~UGraph();
UGraph(ALLOCATION alloc = DEF_ALLOCATION);
UGraph(const UGraph<TObject>& copy_graph);
boolean assign(const UGraph<TObject>& copy_graph);
UGraph<TObject>& operator=(const UGraph<TObject>& arg);
boolean eq(const UGraph<TObject>& compare_vertex) const;
boolean insertArc(long start_index, long end_index, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON, float weight = GraphArc::DEF_WEIGHT);
boolean insertArc(GraphArc<TObject>* start_vertex, GraphArc<TObject>* end_vertex, boolean is_epsilon = GraphArc<TObject>::DEF_EPSILON, float weight = GraphArc::DEF_WEIGHT);
boolean removeArc(long start_index, long end_index);
boolean removeArc(GraphVertex* start_vertex, GraphVertex * end_vertex);
// declare the graph object
//
UGraph<Char> graph(DstrBase::USER);
// perform the required assignments
//
Char* chr_a = new Char(L'a');
GraphVertex<Char>* vertex_a = graph.insertVertex(chr_a);
graph.insertArc(graph.getStart(), vertex_a, true);
Char* chr_b = new Char(L'b');
GraphVertex<Char>* vertex_b = graph.insertVertex(chr_b);
graph.insertArc(graph.getStart(), vertex_b, true);
Char* chr_c = new Char(L'c');
GraphVertex<Char>* vertex_c = graph.insertVertex(chr_c);
graph.insertArc(graph.getStart(), vertex_c, true);
Char* chr_d = new Char(L'd');
GraphVertex<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);