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) GtsGNodeClass; 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) GtsGEdgeClass; 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) GtsGraphClass; GtsGraph; GtsGraphClass* gts_graph_class (void); GtsGraph* gts_graph_new (GtsGraphClass *klass, GtsGNodeClass *node_class, GtsGEdgeClass *edge_class); GtsGraph* gts_graph_read (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); 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) GtsFNode; 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 : |
|
typedef struct { GtsSListContainerClass parent_class; gfloat (* weight) (GtsGNode *); void (* write) (GtsGNode *, FILE *); } GtsGNodeClass;
guint gts_gnode_degree (GtsGNode *n, GtsGraph *g);
n : | a GtsGNode. |
g : | a GtsGraph or NULL. |
Returns : | the number of neighbors of |
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 |
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 |
gfloat gts_gnode_weight (GtsGNode *n);
n : | a GtsGNode. |
Returns : | the weight of |
gfloat gts_gnode_move_cost (GtsGNode *n, GtsGraph *src, GtsGraph *dst);
n : | a GtsGNode. |
src : | a GtsGraph containing |
dst : | another GtsGraph. |
Returns : | the cost (increase in the sum of the weights of the edges cut) of
moving |
typedef struct { GtsContaineeClass parent_class; GtsGEdge * (* link) (GtsGEdge * e, GtsGNode * n1, GtsGNode * n2); gfloat (* weight) (GtsGEdge * e); void (* write) (GtsGEdge * e, FILE * fp); } GtsGEdgeClass;
GtsGEdge* gts_gedge_new (GtsGEdgeClass *klass, GtsGNode *n1, GtsGNode *n2);
klass : | |
n1 : | a GtsGNode. |
n2 : | another GtsGNode. |
Returns : | a new GtsGEdge linking |
gfloat gts_gedge_weight (GtsGEdge *e);
e : | a GtsGEdge. |
Returns : | the weight of edge |
typedef struct { GtsHashContainerClass parent_class; gfloat (* weight) (GtsGraph *); } GtsGraphClass;
typedef struct { GtsHashContainer object; GtsGraphClass * graph_class; GtsGNodeClass * node_class; GtsGEdgeClass * edge_class; } GtsGraph;
GtsGraph* gts_graph_new (GtsGraphClass *klass, GtsGNodeClass *node_class, GtsGEdgeClass *edge_class);
klass : | |
node_class : | |
edge_class : | |
Returns : | a new GtsGraph using |
GtsGraph* gts_graph_read (GtsFile *fp);
Reads a graph from a file.
fp : | a GtsFile. |
Returns : | the new GtsGraph or NULL if an error occured (in which
case the |
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 fp
.
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 |
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
read()
write()
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 |
GtsGraphTraverse* gts_graph_traverse_new (GtsGraph *g, GtsGNode *n, GtsTraverseType type,gboolean reinit);
g : | a GtsGraph. |
n : | a GtsGNode belonging to |
type : | the type of traversal. |
reinit : | if TRUE, the traversal is reinitialized. |
Returns : | a new GtsGraphTraverse initialized for the traversal of
|
GtsGNode* gts_graph_traverse_next (GtsGraphTraverse *t);
t : | |
Returns : | the next GtsGNode of the traversal defined by |
GtsGNode* gts_graph_traverse_what_next (GtsGraphTraverse *t);
t : | |
Returns : | the next GtsGNode of the traversal defined by |
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 |
gfloat gts_graph_edges_cut_weight (GtsGraph *g);
g : | a GtsGraph. |
Returns : | the sum of the weights of the edges of |
guint gts_graph_distance_sum (GtsGraph *g, GtsGNode *center);
g : | a GtsGraph. |
center : | a GtsGNode of |
Returns : | the sum of the distances between all the other GtsGNode
of |
GtsGNode* gts_graph_farthest (GtsGraph *g,GSList *gnodes);
g : | a GtsGraph. |
gnodes : | a list of GtsGNode belonging to |
Returns : | the GtsGNode belonging to |
gfloat gts_graph_weight (GtsGraph *g);
g : | a GtsGraph. |
Returns : | the weight of graph |
GtsFNode* gts_fnode_new (GtsFNodeClass *klass, GtsFace *f);
klass : | |
f : | a GtsFace. |
Returns : | a new GtsFNode associated with face |
GtsGraph* gts_surface_graph_new (GtsGraphClass *klass, GtsSurface *s);
klass : | |
s : | a GtsSurface. |
Returns : | a new GtsGraph representing the connectivity of the faces
of |
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 |
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 |
<<< Graph and operations on graphs | Weighted graph >>> |