GTS Library Reference Manual |
---|
#include <gts.h> #define GTS_GNODE_CLASS (klass) #define GTS_GNODE (obj) #define GTS_IS_GNODE (obj) #define GTS_GNODE_NEIGHBOR (n,e) struct GtsGNodeClass; struct GtsGNode; GtsGNodeClass* gts_gnode_class (void); GtsGNode* gts_gnode_new (GtsGNodeClass *klass);guint gts_gnode_degree (GtsGNode *n, GtsGraph *g); void gts_gnode_foreach_edge (GtsGNode *n, GtsGraph *g, GtsFunc func,gpointer data); void gts_gnode_foreach_neighbor (GtsGNode *n, GtsGraph *g, GtsFunc func,gpointer data);gfloat gts_gnode_weight (GtsGNode *n);gfloat gts_gnode_move_cost (GtsGNode *n, GtsGraph *src, GtsGraph *dst); #define GTS_GEDGE_CLASS (klass) #define GTS_GEDGE (obj) #define GTS_IS_GEDGE (obj) struct GtsGEdgeClass; struct GtsGEdge; GtsGEdgeClass* gts_gedge_class (void); GtsGEdge* gts_gedge_new (GtsGEdgeClass *klass, GtsGNode *n1, GtsGNode *n2);gfloat gts_gedge_weight (GtsGEdge *e); #define gts_gedge_connects (e, a1, a2) #define GTS_GRAPH_CLASS (klass) #define GTS_GRAPH (obj) #define GTS_IS_GRAPH (obj) struct GtsGraphClass; struct GtsGraph; GtsGraphClass* gts_graph_class (void); GtsGraph* gts_graph_new (GtsGraphClass *klass, GtsGNodeClass *node_class, GtsGEdgeClass *edge_class);guint gts_graph_read (GtsGraph *g, GtsFile *fp);guint gts_graph_read_jostle (GtsGraph *g, GtsFile *fp); void gts_graph_write (GtsGraph *g,FILE *fp); void gts_graph_write_dot (GtsGraph *g,FILE *fp); void gts_graph_print_stats (GtsGraph *g,FILE *fp); void gts_graph_foreach_edge (GtsGraph *g, GtsFunc func,gpointer data); struct GtsGraphTraverse; enum GtsTraverseType; GtsGraphTraverse* gts_graph_traverse_new (GtsGraph *g, GtsGNode *n, GtsTraverseType type,gboolean reinit); GtsGNode* gts_graph_traverse_next (GtsGraphTraverse *t); GtsGNode* gts_graph_traverse_what_next (GtsGraphTraverse *t); void gts_graph_traverse_destroy (GtsGraphTraverse *t);guint gts_graph_edges_cut (GtsGraph *g);gfloat gts_graph_edges_cut_weight (GtsGraph *g);guint gts_graph_distance_sum (GtsGraph *g, GtsGNode *center); GtsGNode* gts_graph_farthest (GtsGraph *g,GSList *gnodes);gfloat gts_graph_weight (GtsGraph *g); #define GTS_FNODE_CLASS (klass) #define GTS_FNODE (obj) #define GTS_IS_FNODE (obj) struct GtsFNode; struct GtsFNodeClass; GtsFNodeClass* gts_fnode_class (void); GtsFNode* gts_fnode_new (GtsFNodeClass *klass, GtsFace *f); GtsGraph* gts_surface_graph_new (GtsGraphClass *klass, GtsSurface *s); GtsSurface* gts_surface_graph_surface (GtsGraph *surface_graph, GtsSurface *s); GtsGraph* gts_segments_graph_new (GtsGraphClass *klass,GSList *segments);
#define GTS_GNODE_NEIGHBOR(n,e) (GTS_GEDGE (e)->n1 == n ? GTS_GEDGE (e)->n2 : GTS_GEDGE (e)->n2 == n ? GTS_GEDGE (e)->n1 : NULL)
n : | |
e : |
|
struct GtsGNodeClass { GtsSListContainerClass parent_class; gfloat (* weight) (GtsGNode *); void (* write) (GtsGNode *, FILE *); };
guint gts_gnode_degree (GtsGNode *n, GtsGraph *g);
n : | a GtsGNode. |
g : | a GtsGraph or NULL. |
Returns : | the number of neighbors of n (belonging to g if g is not NULL). |
void gts_gnode_foreach_edge (GtsGNode *n, GtsGraph *g, GtsFunc func,gpointer data);
Calls func for each GtsGEdge connecting n to another GtsGNode (belonging to g if g is not NULL.
n : | a GtsGNode. |
g : | a GtsGraph or NULL. |
func : | a GtsFunc. |
data : | user data to be passed to func. |
void gts_gnode_foreach_neighbor (GtsGNode *n, GtsGraph *g, GtsFunc func,gpointer data);
Calls func for each neighbor GtsGNode of n (belonging to g if g is not NULL.
n : | a GtsGNode. |
g : | a GtsGraph or NULL. |
func : | a GtsFunc. |
data : | user data to be passed to func. |
gfloat gts_gnode_weight (GtsGNode *n);
n : | a GtsGNode. |
Returns : | the weight of n as defined by the |
gfloat gts_gnode_move_cost (GtsGNode *n, GtsGraph *src, GtsGraph *dst);
n : | a GtsGNode. |
src : | a GtsGraph containing n. |
dst : | another GtsGraph. |
Returns : | the cost (increase in the sum of the weights of the edges cut) of moving n from src to dst. |
struct GtsGEdgeClass { GtsContaineeClass parent_class; GtsGEdge * (* link) (GtsGEdge * e, GtsGNode * n1, GtsGNode * n2); gfloat (* weight) (GtsGEdge * e); void (* write) (GtsGEdge * e, FILE * fp); };
GtsGEdge* gts_gedge_new (GtsGEdgeClass *klass, GtsGNode *n1, GtsGNode *n2);
klass : | |
n1 : | a GtsGNode. |
n2 : | another GtsGNode. |
Returns : | a new GtsGEdge linking n1 and n2. |
gfloat gts_gedge_weight (GtsGEdge *e);
e : | a GtsGEdge. |
Returns : | the weight of edge e as defined by the |
struct GtsGraphClass { GtsHashContainerClass parent_class; gfloat (* weight) (GtsGraph *); };
struct GtsGraph { GtsHashContainer object; GtsGNodeClass * node_class; GtsGEdgeClass * edge_class; };
GtsGraph* gts_graph_new (GtsGraphClass *klass, GtsGNodeClass *node_class, GtsGEdgeClass *edge_class);
klass : | |
node_class : | |
edge_class : | |
Returns : | a new GtsGraph using node_class and edge_class as node types. |
guint gts_graph_read (GtsGraph *g, GtsFile *fp);
Adds to g the data read from fp. The format of the file pointed to by fp is as described in gts_graph_write().
g : | a GtsGraph. |
fp : | a GtsFile. |
Returns : | 0 if successful or the line number at which the parsing stopped in case of error (in which case the error field of fp is set). |
guint gts_graph_read_jostle (GtsGraph *g, GtsFile *fp);
Adds to g the nodes and edges defined in the file pointed to by
fp. This file must use the Jostle "graph" ASCII format.
The nodes created are of type
g : | a GtsGraph. |
fp : | a GtsFile. |
Returns : | 0 if the lecture was successful, the line number at which an error occured otherwise (in which case the error field of fp is set). |
void gts_graph_write (GtsGraph *g,FILE *fp);
Writes in the file fp an ASCII representation of g. The file format is as follows.
All the lines beginning with GTS_COMMENTS are ignored. The first line contains two unsigned integers separated by spaces. The first integer is the number of nodes, nn, the second is the number of edges, ne.
Follows nn lines containing node description. Follows ne lines containing the two indices (starting from one) of the nodes of each edge.
The format described above is the least common denominator to all
GTS files. Consistent with an object-oriented approach, the GTS
file format is extensible. Each of the lines of the file can be
extended with user-specific attributes accessible through the
g : | a GtsGraph. |
fp : | a file pointer. |
void gts_graph_write_dot (GtsGraph *g,FILE *fp);
Writes in the file fp an ASCII representation of g in the dot format of AT&T Bell Labs.
g : | a GtsGraph. |
fp : | a file pointer. |
void gts_graph_print_stats (GtsGraph *g,FILE *fp);
Writes to fp a summary of the properties of g.
g : | a GtsGraph. |
fp : | a file pointer. |
void gts_graph_foreach_edge (GtsGraph *g, GtsFunc func,gpointer data);
Calls func for each GtsEdge of g.
g : | a GtsGraph. |
func : | a GtsFunc. |
data : | user data to be passed to func. |
GtsGraphTraverse* gts_graph_traverse_new (GtsGraph *g, GtsGNode *n, GtsTraverseType type,gboolean reinit);
g : | a GtsGraph. |
n : | a GtsGNode belonging to g. |
type : | the type of traversal. |
reinit : | if TRUE, the traversal is reinitialized. |
Returns : | a new GtsGraphTraverse initialized for the traversal of g of type type, starting from n. |
GtsGNode* gts_graph_traverse_next (GtsGraphTraverse *t);
t : | |
Returns : | the next GtsGNode of the traversal defined by t or NULL if the traversal is complete. |
GtsGNode* gts_graph_traverse_what_next (GtsGraphTraverse *t);
t : | |
Returns : | the next GtsGNode of the traversal defined by t or NULL if the traversal is complete but without advancing the traversal. |
void gts_graph_traverse_destroy (GtsGraphTraverse *t);
Frees all the memory allocated for t.
t : |
guint gts_graph_edges_cut (GtsGraph *g);
g : | a GtsGraph. |
Returns : | the number of edges of g connecting nodes belonging to g to nodes not belonging to g. |
gfloat gts_graph_edges_cut_weight (GtsGraph *g);
g : | a GtsGraph. |
Returns : | the sum of the weights of the edges of g connecting nodes belonging to g to nodes not belonging to g. |
guint gts_graph_distance_sum (GtsGraph *g, GtsGNode *center);
g : | a GtsGraph. |
center : | a GtsGNode of g. |
Returns : | the sum of the distances between all the other GtsGNode of g and center. |
GtsGNode* gts_graph_farthest (GtsGraph *g,GSList *gnodes);
g : | a GtsGraph. |
gnodes : | a list of GtsGNode belonging to g. |
Returns : | the GtsGNode belonging to g and farthest from all the nodes in gnodes (hmmm, definition of "farthest"?). |
gfloat gts_graph_weight (GtsGraph *g);
g : | a GtsGraph. |
Returns : | the weight of graph g as defined by the |
GtsFNode* gts_fnode_new (GtsFNodeClass *klass, GtsFace *f);
klass : | |
f : | a GtsFace. |
Returns : | a new GtsFNode associated with face f. |
GtsGraph* gts_surface_graph_new (GtsGraphClass *klass, GtsSurface *s);
klass : | |
s : | a GtsSurface. |
Returns : | a new GtsGraph representing the connectivity of the faces
of s. This graph uses |
GtsSurface* gts_surface_graph_surface (GtsGraph *surface_graph, GtsSurface *s);
surface_graph : | a GtsGraph using |
s : | a GtsSurface. |
Returns : | a new GtsSurface using the same classes as s and composed of the faces defined by surface_graph. |
GtsGraph* gts_segments_graph_new (GtsGraphClass *klass,GSList *segments);
klass : | |
segments : | a list of GtsSegment. |
Returns : | a new GtsGraph representing the connectivity of the segments in segments. |
<<< Graph and operations on graphs | Weighted graph >>> |